MissingPackageSolution   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 35
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getSolutionTitle() 0 4 1
A getSolutionDescription() 0 11 1
A getDocumentationLinks() 0 7 1
1
<?php
2
3
namespace Facade\Ignition\Solutions;
4
5
use Facade\Ignition\Support\Packagist\Package;
6
use Facade\IgnitionContracts\Solution;
7
8
class MissingPackageSolution implements Solution
9
{
10
    /** @var \Facade\Flare\Support\Packagist\Package */
11
    protected $possiblePackage;
12
13
    public function __construct(Package $possiblePackage)
14
    {
15
        $this->possiblePackage = $possiblePackage;
0 ignored issues
show
Documentation Bug introduced by
It seems like $possiblePackage of type object<Facade\Ignition\Support\Packagist\Package> is incompatible with the declared type object<Facade\Flare\Support\Packagist\Package> of property $possiblePackage.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
16
    }
17
18
    public function getSolutionTitle(): string
19
    {
20
        return 'A composer dependency is missing';
21
    }
22
23
    public function getSolutionDescription(): string
24
    {
25
        $output = [
26
            'You might be missing a composer dependency.',
27
            'A possible package that was found is `'.$this->possiblePackage->name.'`.',
28
            '',
29
            'See if this is the package that you need and install it via `composer require '.$this->possiblePackage->name.'`.',
30
        ];
31
32
        return implode(PHP_EOL, $output);
33
    }
34
35
    public function getDocumentationLinks(): array
36
    {
37
        return [
38
            'Git repository' => $this->possiblePackage->repository,
39
            'Package on Packagist' => $this->possiblePackage->url,
40
        ];
41
    }
42
}
43