* Find class in namespaces or definitions directories * @param string $class * @return string */
($class)
| 128 | * @return string |
| 129 | */ |
| 130 | public function findFile($class) |
| 131 | { |
| 132 | // Remove first backslash |
| 133 | if ('\\' == $class[0]) { |
| 134 | $class = substr($class, 1); |
| 135 | } |
| 136 | |
| 137 | if (false !== $pos = strrpos($class, '\\')) { |
| 138 | // Namespaced class name |
| 139 | $namespace = substr($class, 0, $pos); |
| 140 | |
| 141 | // Iterate in normal namespaces |
| 142 | foreach ($this->namespaces as $ns => $dirs) { |
| 143 | //Don't interfere with other autoloaders |
| 144 | if (0 !== strpos($namespace, $ns)) { |
| 145 | continue; |
| 146 | } |
| 147 | |
| 148 | foreach ($dirs as $dir) { |
| 149 | $className = substr($class, $pos + 1); |
| 150 | |
| 151 | $file = $dir . DIRECTORY_SEPARATOR . |
| 152 | str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . |
| 153 | DIRECTORY_SEPARATOR . |
| 154 | $className . '.php'; |
| 155 | |
| 156 | if (file_exists($file)) { |
| 157 | return $file; |
| 158 | } |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | // Iterate in Thrift namespaces |
| 163 | |
| 164 | // Remove first part of namespace |
| 165 | $m = explode('\\', $class); |
| 166 | |
| 167 | // Ignore wrong call |
| 168 | if (count($m) <= 1) { |
| 169 | #HOW TO TEST THIS? HOW TEST CASE SHOULD LOOK LIKE? |
| 170 | return; |
| 171 | } |
| 172 | |
| 173 | $class = array_pop($m); |
| 174 | $namespace = implode('\\', $m); |
| 175 | |
| 176 | foreach ($this->definitions as $ns => $dirs) { |
| 177 | //Don't interfere with other autoloaders |
| 178 | if (0 !== strpos($namespace, $ns)) { |
| 179 | continue; |
| 180 | } |
| 181 | |
| 182 | foreach ($dirs as $dir) { |
| 183 | /** |
| 184 | * Available in service: Interface, Client, Processor, Rest |
| 185 | * And every service methods (_.+) |
| 186 | */ |
| 187 | if (0 === preg_match('#(.+)(if|client|processor|rest)$#i', $class, $n) |
no outgoing calls
no test coverage detected