Passed
Push — master ( 0cfc7e...b88fc1 )
by Tom
03:33 queued 42s
created

Artifacts::__construct()   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
/* this file is part of pipelines */
4
5
namespace Ktomk\Pipelines\File;
6
7
/**
8
 * Artifacts of a pipelines step
9
 *
10
 * @package Ktomk\Pipelines\File
11
 */
12
class Artifacts
13
{
14
    /**
15
     * @var array|string[]
16
     */
17
    private $artifacts;
18
19
    /**
20
     * Artifacts constructor.
21
     *
22
     * @param array|string[] $artifacts
23
     */
24 4
    public function __construct($artifacts)
25
    {
26 4
        $this->parse($artifacts);
27 2
    }
28
29
    /**
30
     * @return array|string[]
31
     */
32 1
    public function getPatterns()
33
    {
34 1
        return $this->artifacts;
35
    }
36
37
    /**
38
     * @param array|string[] $artifacts
39
     */
40 4
    private function parse($artifacts)
41
    {
42
        // quick validation: requires a list of strings
43 4
        if (!is_array($artifacts) || !count($artifacts)) {
44 1
            ParseException::__("'artifacts' requires a list");
45
        }
46
47 3
        foreach ($artifacts as $index => $string) {
48 3
            if (!is_string($string)) {
49 1
                ParseException::__(sprintf(
50 1
                    "'artifacts' requires a list of strings, #%d is not a string",
51 3
                    $index
52
                ));
53
            }
54
        }
55
56 2
        $this->artifacts = $artifacts;
57 2
    }
58
}
59