hiqdev /
hidev
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace hidev\components; |
||||
| 4 | |||||
| 5 | use hidev\helpers\Sys; |
||||
| 6 | |||||
| 7 | class Composer |
||||
| 8 | { |
||||
| 9 | public function __construct(string $dir) |
||||
| 10 | { |
||||
| 11 | $this->dir = ($dir === getcwd() ? '' : $dir); |
||||
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||||
| 12 | } |
||||
| 13 | |||||
| 14 | public function autoload() |
||||
| 15 | { |
||||
| 16 | $path = $this->getPath('vendor/autoload.php'); |
||||
| 17 | if (!file_exists($path)) { |
||||
| 18 | $this->run('update'); |
||||
| 19 | } |
||||
| 20 | require $path; |
||||
| 21 | } |
||||
| 22 | |||||
| 23 | public function dump() |
||||
| 24 | { |
||||
| 25 | $this->run('dump-autoload'); |
||||
| 26 | } |
||||
| 27 | |||||
| 28 | public function run(string $command, array $args = []) |
||||
|
0 ignored issues
–
show
The parameter
$args is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
|
|||||
| 29 | { |
||||
| 30 | Sys::passthru("{$this->getCmd()} $command"); |
||||
| 31 | } |
||||
| 32 | |||||
| 33 | public function getCmd(): string |
||||
| 34 | { |
||||
| 35 | return 'composer' . ($this->dir ? " -d $dir" : ''); |
||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
| 36 | } |
||||
| 37 | |||||
| 38 | public function getPath(string $file): string |
||||
| 39 | { |
||||
| 40 | if (strncmp($file, '/', 1) === 0) { |
||||
| 41 | return $file; |
||||
| 42 | } |
||||
| 43 | |||||
| 44 | return $this->dir ? $this->dir . DIRECTORY_SEPARATOR . $file : $file; |
||||
| 45 | } |
||||
| 46 | } |
||||
| 47 |