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

Dependencies::from()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 3
rs 10
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