Total Complexity | 3 |
Total Lines | 27 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
20 | final class Composer implements PathResolver |
||
21 | { |
||
22 | private $vendorPath; |
||
23 | |||
24 | public function __construct() |
||
25 | { |
||
26 | 8 | $composer = Sequence::of(...get_declared_classes())->filter(static function(string $class): bool { |
|
27 | 8 | return (string) Str::of($class)->substring(0, 22) === 'ComposerAutoloaderInit'; |
|
28 | 8 | }); |
|
29 | |||
30 | //use the last as there may be 2 classes, the first being the global autoloader |
||
31 | 8 | $refl = new \ReflectionClass((string) $composer->last()); |
|
32 | 8 | $vendorPath = dirname(dirname($refl->getFileName())); |
|
33 | |||
34 | 8 | $this->vendorPath = Str::of($vendorPath)->append('/'); |
|
35 | 8 | } |
|
36 | |||
37 | 4 | public function __invoke(PathInterface $from, PathInterface $to): PathInterface |
|
47 | ); |
||
48 | } |
||
50 |