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

File::get()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
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
}