/** * find the first method on $target that matches $data's data type * * @param mixed $data * the data we want to call $target with * @param string|object $target * the target that we want to call * @param string $methodPrefix * the prefix at the front of methods on $target * @return string|null * the method that suits $data the best */ private static function findFirstMatchingMethod($data, $target, $methodPrefix) { // no, so we need to build it $possibleTypes = AllMatchingTypesList::from($data); $possibleMethods = CallableMethodsList::from($target); foreach ($possibleTypes as $possibleType) { $targetMethodName = $methodPrefix . FilterNamespace::fromString($possibleType); if (isset($possibleMethods[$targetMethodName])) { // all done return $targetMethodName; } } // no match return null; }
/** * @covers ::fromString * @dataProvider namespaceList */ public function testCanStripNamespaces($classname, $expectedResult) { $actualResult = FilterNamespace::fromString($classname); $this->assertEquals($expectedResult, $actualResult); }