Passed
Push — master ( 28f242...472b4c )
by Gabriel
04:44
created

HasPathsTrait   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 76.92%

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 40
ccs 10
cts 13
cp 0.7692
rs 10
c 0
b 0
f 0
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A paths() 0 3 1
A addBasePath() 0 4 1
A path() 0 3 1
A setPath() 0 4 2
1
<?php
2
3
namespace ByTIC\Migrations\Config\Traits;
4
5
/**
6
 * Trait HasPathsTrait
7
 * @package ByTIC\Migrations\Config\Traits
8
 */
9
trait HasPathsTrait
10
{
11
    /**
12
     * @param $path
13
     */
14 1
    public function addBasePath($path)
15
    {
16 1
        $this->setPath($path . DIRECTORY_SEPARATOR . 'migrations', 'migrations');
17 1
        $this->setPath($path . DIRECTORY_SEPARATOR . 'seeds', 'seeds');
18 1
    }
19
20
    /**
21
     * @param $type
22
     * @param $path
23
     */
24 3
    public function setPath($path, $type = 'migrations')
25
    {
26 3
        $path = is_array($path) ? $path : [$path];
27 3
        $this->params['paths'][$type] = $path;
0 ignored issues
show
Bug Best Practice introduced by
The property params does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
28 3
    }
29
30
    /**
31
     * Register a custom migration path.
32
     *
33
     * @param string $path
34
     * @param string $type
35
     * @return void
36
     */
37
    public function path($path, $type = 'migrations')
38
    {
39
        $this->params['paths'][$type] = array_unique(array_merge($this->params['paths'][$type], [$path]));
0 ignored issues
show
Bug Best Practice introduced by
The property params does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
40
    }
41
42
    /**
43
     * @param string $type
44
     * @return mixed
45
     */
46 1
    public function paths($type = 'migrations')
47
    {
48 1
        return $this->params['paths'][$type];
49
    }
50
}