/** * @covers ::from * @dataProvider provideDataToTest */ public function testCanCallStatically($data, $expectedNamespace) { // ---------------------------------------------------------------- // setup your test // ---------------------------------------------------------------- // perform the change $actualNamespace = GetNamespace::from($data); // ---------------------------------------------------------------- // test the results $this->assertEquals($expectedNamespace, $actualNamespace); }
/** * what namespace does a class live within? * * @param string|object $item * the item to examine * @return string * the class's namespace * @throws InvalidArgumentException * - if we have not been given a string or object * - if the string does not contain the name of a defined * class / interface / trait */ function get_namespace($item) { return GetNamespace::from($item); }
/** * is the given classname NOT in our list to filter out? * * @param string $className * the fully-qualified class name to check * @param array $filterList * the list of classes and namespaces to filter for * @return boolean * TRUE if the classname is NOT in our list of partial namespaces * FALSE otherwise */ private static function isClassNameOkay($className, $filterList) { // the caller may be trying to filter out the class itself, or the // namespace that the class is inside. $searchList = [GetNamespace::from($className), $className]; if (empty(array_intersect($filterList, $searchList))) { return true; } // if we get here, then this class isn't one that we want to return // to the caller return false; }