Conditions | 6 |
Paths | 11 |
Total Lines | 42 |
Code Lines | 24 |
Lines | 0 |
Ratio | 0 % |
Tests | 21 |
CRAP Score | 6.0702 |
Changes | 3 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
13 | 5 | public function getResult(): array |
|
14 | { |
||
15 | 5 | $result = []; |
|
16 | |||
17 | 5 | foreach ($this->assetsCollection as $asset) { |
|
18 | 5 | if ($asset->getPath() === false) { |
|
19 | continue; |
||
20 | } |
||
21 | |||
22 | 5 | if ($asset->isUrl()) { |
|
23 | 5 | $result[] = $asset->getPath(); |
|
24 | 5 | continue; |
|
25 | } |
||
26 | |||
27 | 2 | $link = str_replace( |
|
28 | [ |
||
29 | 2 | $this->environment->getCompileDir(), |
|
30 | 2 | $this->environment->getProjectDir() |
|
31 | ] |
||
32 | , |
||
33 | 2 | '', |
|
34 | 2 | $asset->getPath() |
|
35 | ); |
||
36 | |||
37 | 2 | $symlink = $this->environment->getCompileDir() . $link; |
|
38 | |||
39 | try { |
||
40 | 2 | if (!file_exists($symlink)) { |
|
41 | 2 | $path = pathinfo($symlink, PATHINFO_DIRNAME); |
|
42 | 2 | Helpers::createDirectory($path); |
|
|
|||
43 | 2 | $this->logger->info(sprintf('Create directory %s', $path)); |
|
44 | |||
45 | 2 | symlink($asset->getPath(), $symlink); |
|
46 | 2 | $this->logger->info(sprintf('Create symlink: %s', $symlink)); |
|
47 | } |
||
48 | } catch (\Exception $e) { |
||
49 | $this->logger->error($e->getMessage()); |
||
50 | } |
||
51 | |||
52 | 2 | $result[] = $this->environment->getBaseUrl() . str_replace(DIRECTORY_SEPARATOR, '/', $link); |
|
53 | } |
||
54 | 5 | return $result; |
|
55 | } |
||
57 |