Composer   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
eloc 10
dl 0
loc 34
c 0
b 0
f 0
ccs 0
cts 11
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A installed() 0 9 1
A install() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FondBot\Foundation;
6
7
use Illuminate\Support\Composer as BaseComposer;
8
9
class Composer extends BaseComposer
10
{
11
    /**
12
     * Install a package.
13
     *
14
     * @param string   $package
15
     * @param callable $callback
16
     *
17
     * @return int
18
     */
19
    public function install(string $package, callable $callback): int
20
    {
21
        return $this->getProcess()
22
            ->setCommandLine($this->findComposer().' require '.$package)
23
            ->run($callback);
24
    }
25
26
    /**
27
     * Determine if package already installed.
28
     *
29
     * @param string $package
30
     *
31
     * @return bool
32
     * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
33
     */
34
    public function installed(string $package): bool
35
    {
36
        $manifest = $this->files->get('composer.json');
37
        $manifest = json_decode($manifest, true);
38
39
        return collect($manifest['require'])
40
            ->merge($manifest['require-dev'])
41
            ->keys()
42
            ->contains($package);
43
    }
44
}
45