Completed
Push — master ( 816440...cac82f )
by Vladimir
12:37
created

Composer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 35
ccs 0
cts 11
cp 0
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A install() 0 6 1
A installed() 0 10 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
     */
33
    public function installed(string $package): bool
34
    {
35
        $manifest = $this->files->get('composer.json');
36
        $manifest = json_decode($manifest, true);
37
38
        return collect($manifest['require'])
39
            ->merge($manifest['require-dev'])
40
            ->keys()
41
            ->contains($package);
42
    }
43
}
44