Conditions | 6 |
Paths | 9 |
Total Lines | 42 |
Code Lines | 21 |
Lines | 0 |
Ratio | 0 % |
Tests | 16 |
CRAP Score | 6.288 |
Changes | 4 | ||
Bugs | 2 | Features | 0 |
1 | <?php |
||
14 | 8 | public function getResult(): array |
|
15 | { |
||
16 | 8 | $result = []; |
|
17 | |||
18 | 8 | foreach ($this->assetsCollection as $asset) { |
|
19 | 8 | if (false === $path = $asset->getPath()) { |
|
20 | continue; |
||
21 | } |
||
22 | |||
23 | 8 | if ($asset->isUrl()) { |
|
24 | 5 | $result[] = $path; |
|
25 | 5 | continue; |
|
26 | } |
||
27 | |||
28 | 5 | $link = str_replace( |
|
29 | [ |
||
30 | 5 | $this->environment->getCompileDir(), |
|
31 | 5 | $this->environment->getProjectDir() |
|
32 | ] |
||
33 | , |
||
34 | 5 | '', |
|
35 | $path |
||
36 | ); |
||
37 | |||
38 | try { |
||
39 | 5 | Helpers::createSymlink($this->environment->getCompileDir() . $link, $path, $this->logger); |
|
40 | |||
41 | 5 | $optSymlinks = (array)$asset->getOption(Asset::CREATE_SYMLINK, []); |
|
42 | |||
43 | /** @var array<string, string> $optSymlinks */ |
||
44 | 5 | foreach ($optSymlinks as $optLink => $optTarget) { |
|
45 | Helpers::createSymlink($optLink, $optTarget, $this->logger); |
||
46 | } |
||
47 | } catch (\Exception $e) { |
||
48 | $this->logger->error($e->getMessage()); |
||
49 | } |
||
50 | |||
51 | |||
52 | 5 | $result[] = $this->environment->getBaseUrl() . str_replace(DIRECTORY_SEPARATOR, '/', $link); |
|
53 | } |
||
54 | |||
55 | 8 | return $result; |
|
56 | } |
||
58 |