Passed
Push — master ( f54951...16bf4d )
by Stephen
04:34
created

Dependencies   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
eloc 5
c 2
b 0
f 0
dl 0
loc 44
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A fromConfig() 0 3 1
A from() 0 3 1
A fromComposer() 0 3 1
A fromArray() 0 3 1
1
<?php
2
3
namespace Sfneal\Dependencies;
4
5
use Sfneal\Dependencies\Services\DependenciesRepository;
6
use Sfneal\Dependencies\Services\DependencyService;
7
8
class Dependencies
9
{
10
    /**
11
     * Retrieve a DependencyService for a single package.
12
     *
13
     * @param  string  $type
14
     * @param  string  $package
15
     * @return DependencyService
16
     */
17
    public static function from(string $type, string $package): DependencyService
18
    {
19
        return new DependencyService($package, $type);
20
    }
21
22
    /**
23
     * Retrieve dependencies from the composer.json file & optionally include 'dev' dependencies.
24
     *
25
     * @param  bool  $devComposerDependencies
26
     * @return DependenciesRepository
27
     */
28
    public static function fromComposer(bool $devComposerDependencies = false): DependenciesRepository
29
    {
30
        return (new DependenciesRepository())->fromComposer($devComposerDependencies);
31
    }
32
33
    /**
34
     * Retrieve dependencies from the config file.
35
     *
36
     * @return DependenciesRepository
37
     */
38
    public static function fromConfig(): DependenciesRepository
39
    {
40
        return (new DependenciesRepository())->fromConfig();
41
    }
42
43
    /**
44
     * Retrieve dependencies from an array.
45
     *
46
     * @param  array  $dependencies
47
     * @return DependenciesRepository
48
     */
49
    public static function fromArray(array $dependencies): DependenciesRepository
50
    {
51
        return (new DependenciesRepository())->fromArray($dependencies);
52
    }
53
}
54