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

HasPathsTrait::paths()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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