Passed
Push — master ( d8d9f2...800fb3 )
by Tom
02:30
created

Project   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 12
c 1
b 0
f 1
dl 0
loc 63
ccs 16
cts 16
cp 1
rs 10
wmc 7

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __toString() 0 3 1
A setPrefix() 0 3 1
A getName() 0 3 1
A getPrefix() 0 3 1
A getPath() 0 3 1
A __construct() 0 7 2
1
<?php
2
3
/* this file is part of pipelines */
4
5
namespace Ktomk\Pipelines;
6
7
use InvalidArgumentException;
8
use Ktomk\Pipelines\Value\Prefix;
9
10
/**
11
 * Class Project
12
 *
13
 * Represents the project pipelines is running/operating on
14
 *
15
 * @package Ktomk\Pipelines
16
 */
17
class Project
18
{
19
    /**
20
     * @var string path to the project directory on user/host system
21
     */
22
    private $path;
23
24
    /**
25
     * @var string prefix ('pipelines' by default)
26
     */
27
    private $prefix;
28
29
    /**
30
     * Project constructor.
31
     *
32
     * @param string $path
33
     */
34 5
    public function __construct($path)
35
    {
36 5
        $buffer = LibFsPath::normalize($path);
37 5
        if (!basename($buffer)) {
38 1
            throw new InvalidArgumentException(sprintf('Invalid project directory: "%s"', $path));
39
        }
40 4
        $this->path = $buffer;
41 4
    }
42
43
    /**
44
     *
45
     */
46 1
    public function __toString()
47
    {
48 1
        return $this->getName();
49
    }
50
51 2
    public function getName()
52
    {
53 2
        return basename($this->path);
54
    }
55
56
    /**
57
     * @return string
58
     */
59 1
    public function getPath()
60
    {
61 1
        return $this->path;
62
    }
63
64
    /**
65
     * @return string
66
     */
67 1
    public function getPrefix()
68
    {
69 1
        return $this->prefix;
70
    }
71
72
    /**
73
     * @param string $prefix
74
     *
75
     * @throws InvalidArgumentException
76
     */
77 1
    public function setPrefix($prefix)
78
    {
79 1
        $this->prefix = Prefix::verify($prefix);
80 1
    }
81
}
82