1 | <?php namespace Arcanesoft\Foundation\ViewComposers\System; |
||||
2 | |||||
3 | use Illuminate\View\View; |
||||
0 ignored issues
–
show
|
|||||
4 | use RecursiveDirectoryIterator; |
||||
5 | use RecursiveIteratorIterator; |
||||
6 | |||||
7 | /** |
||||
8 | * Class ApplicationInfoComposer |
||||
9 | * |
||||
10 | * @package Arcanesoft\Foundation\ViewComposers\System |
||||
11 | * @author ARCANEDEV <[email protected]> |
||||
12 | */ |
||||
13 | class ApplicationInfoComposer |
||||
14 | { |
||||
15 | /* ----------------------------------------------------------------- |
||||
16 | | Constants |
||||
17 | | ----------------------------------------------------------------- |
||||
18 | */ |
||||
19 | |||||
20 | const VIEW = 'foundation::admin.system.information._includes.application'; |
||||
21 | |||||
22 | /* ----------------------------------------------------------------- |
||||
23 | | Main Methods |
||||
24 | | ----------------------------------------------------------------- |
||||
25 | */ |
||||
26 | |||||
27 | /** |
||||
28 | * Compose the view. |
||||
29 | * |
||||
30 | * @param \Illuminate\View\View $view |
||||
31 | */ |
||||
32 | public function compose(View $view) |
||||
33 | { |
||||
34 | $app = app(); |
||||
0 ignored issues
–
show
The function
app was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
35 | |||||
36 | $view->with('application', [ |
||||
37 | 'url' => config('app.url'), |
||||
0 ignored issues
–
show
The function
config was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
38 | 'locale' => strtoupper(config('app.locale')), |
||||
39 | 'timezone' => config('app.timezone'), |
||||
40 | 'debug_mode' => config('app.debug', false), |
||||
41 | 'maintenance_mode' => $app->isDownForMaintenance(), |
||||
42 | 'arcanesoft_version' => foundation()->version(), |
||||
43 | 'laravel_version' => $app->version(), |
||||
44 | 'app_size' => $this->getApplicationSize(), |
||||
45 | 'database_connection' => config('database.default'), |
||||
46 | 'cache_driver' => config('cache.default'), |
||||
47 | 'session_driver' => config('session.driver') |
||||
48 | ]); |
||||
49 | } |
||||
50 | |||||
51 | /* ----------------------------------------------------------------- |
||||
52 | | Other Methods |
||||
53 | | ----------------------------------------------------------------- |
||||
54 | */ |
||||
55 | |||||
56 | /** |
||||
57 | * Get the application size. |
||||
58 | * |
||||
59 | * @return string |
||||
60 | */ |
||||
61 | private function getApplicationSize() |
||||
62 | { |
||||
63 | $size = cache()->remember('foundation.app.size', 5, function () { |
||||
0 ignored issues
–
show
The function
cache was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
64 | return $this->getFolderSize(base_path()); |
||||
0 ignored issues
–
show
The function
base_path was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
65 | }); |
||||
66 | |||||
67 | return $this->formatSize($size); |
||||
68 | } |
||||
69 | |||||
70 | /** |
||||
71 | * Get the folder size. |
||||
72 | * |
||||
73 | * @param string $path |
||||
74 | * |
||||
75 | * @return int |
||||
76 | */ |
||||
77 | private function getFolderSize($path) |
||||
78 | { |
||||
79 | $size = 0; |
||||
80 | |||||
81 | foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)) as $directory) { |
||||
82 | /** @var \SplFileInfo $directory */ |
||||
83 | $size += $directory->getSize(); |
||||
84 | } |
||||
85 | |||||
86 | return $size; |
||||
87 | } |
||||
88 | |||||
89 | /** |
||||
90 | * Format the size for humans. |
||||
91 | * |
||||
92 | * @param int $bytes |
||||
93 | * |
||||
94 | * @return string |
||||
95 | */ |
||||
96 | private function formatSize($bytes) |
||||
97 | { |
||||
98 | $kb = 1024; |
||||
99 | $mb = $kb * 1024; |
||||
100 | $gb = $mb * 1024; |
||||
101 | $tb = $gb * 1024; |
||||
102 | |||||
103 | if (($bytes >= 0) && ($bytes < $kb)) { |
||||
104 | return $bytes . ' B'; |
||||
105 | } |
||||
106 | elseif (($bytes >= $kb) && ($bytes < $mb)) { |
||||
107 | return ceil($bytes / $kb).' KB'; |
||||
108 | } |
||||
109 | elseif (($bytes >= $mb) && ($bytes < $gb)) { |
||||
110 | return ceil($bytes / $mb).' MB'; |
||||
111 | } |
||||
112 | elseif (($bytes >= $gb) && ($bytes < $tb)) { |
||||
113 | return ceil($bytes / $gb).' GB'; |
||||
114 | } |
||||
115 | elseif ($bytes >= $tb) { |
||||
116 | return ceil($bytes / $tb).' TB'; |
||||
117 | } |
||||
118 | |||||
119 | return $bytes.' B'; |
||||
120 | } |
||||
121 | } |
||||
122 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths