Passed
Push — master ( 0fb5fb...9b0d5c )
by Chubarov
02:40
created

File   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 36
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 2
A getName() 0 3 1
A get() 0 4 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Cart\SourcesConfigurations;
5
6
use Cart\Contracts\SourceConfiguration;
7
use Mockery\Exception;
8
9
class File implements SourceConfiguration
10
{
11
    protected $name = 'cart';
12
13 3
    public function __construct(string $path = '')
14
    {
15 3
        if (file_exists($path)) {
16 2
            $this->pathToFile = $path;
17
        } else {
18 1
            throw new Exception('Local file name is not exist.');
19
        }
20 2
    }
21
    /**
22
     * @var string
23
     */
24
    protected $pathToFile;
25
26
    /**
27
     * get array with configuration
28
     * @return array
29
     */
30
31 2
    public function get() : array
32
    {
33 2
        $configuration =  require $this->pathToFile;
34 2
        return $configuration;
35
    }
36
37
    /**
38
     * Get name
39
     *
40
     * @return string
41
     */
42 2
    public function getName(): string
43
    {
44 2
        return $this->name;
45
    }
46
}