/** * throws exceptions if $path is not a valid dot.notation.support path * * @param string $path * the path to check * @param string $eUnsupportedType * the class to use when throwing an unsupported-type exception * @param string $eNotDotNotationPath * the class to use when throwing a not-dot-notation-path exception * @return void */ public static function check($path, $eUnsupportedType = E4xx_UnsupportedType::class, $eNotDotNotationPath = E4xx_NotDotNotationPath::class) { // make sure we have a string RequireStringy::check($path, $eUnsupportedType); // make sure the string contains a dot.notation.support path if (!IsDotNotationPath::checkString($path)) { throw new $eNotDotNotationPath($path); } }
/** * magic method, called when we want to know if a fake property exists * or not * * if $propertyName is a dot.notation.support path, we'll attempt to * follow it to find the stated property * * @param string $propertyName * name of the property to search for * @return boolean * TRUE if the property exists (or is emulated) * FALSE otherwise */ public function __isset($propertyName) { // is the user trying to use dot.notation? if (IsDotNotationPath::checkString($propertyName)) { return HasUsingDotNotationPath::inObject($this, $propertyName); } // if we get here, the property does not exist return false; }
/** * @covers ::checkString * @covers ::nothingMatchesTheInputType * @expectedException GanbaroDigital\DataContainers\Exceptions\E4xx_UnsupportedType * @dataProvider provideNonStrings */ public function testThrowsExceptionIfPathIsNotAString($path) { // ---------------------------------------------------------------- // setup your test // ---------------------------------------------------------------- // perform the change IsDotNotationPath::check($path); }