|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* this file is part of pipelines */ |
|
4
|
|
|
|
|
5
|
|
|
namespace Ktomk\Pipelines\File\Info; |
|
6
|
|
|
|
|
7
|
|
|
use Ktomk\Pipelines\File\File; |
|
8
|
|
|
use Ktomk\Pipelines\File\Pipeline\Step; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* info about a step (for show output) |
|
12
|
|
|
*/ |
|
13
|
|
|
final class StepInfo |
|
14
|
|
|
{ |
|
15
|
|
|
const NO_NAME = 'no-name'; |
|
16
|
|
|
const CHAR_MANUAL = 'M'; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @var Step |
|
20
|
|
|
*/ |
|
21
|
|
|
private $step; |
|
22
|
|
|
private $index; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @param Step $step |
|
26
|
|
|
* @param int $index (zero-based) |
|
27
|
|
|
*/ |
|
28
|
2 |
|
public function __construct(Step $step, $index) |
|
29
|
|
|
{ |
|
30
|
2 |
|
$this->step = $step; |
|
31
|
2 |
|
$this->index = (int)$index; |
|
32
|
2 |
|
} |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @param string $string |
|
36
|
|
|
* @param string $separator [optional] |
|
37
|
|
|
* |
|
38
|
|
|
* @return string |
|
39
|
|
|
*/ |
|
40
|
1 |
|
public function annotate($string, $separator = ' *') |
|
41
|
|
|
{ |
|
42
|
1 |
|
$buffer = (string)$string; |
|
43
|
1 |
|
$annotations = $this->getAnnotations(); |
|
44
|
1 |
|
if ($annotations) { |
|
45
|
1 |
|
$buffer .= $separator . implode('', $annotations); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
1 |
|
return $buffer; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @return array |
|
53
|
|
|
*/ |
|
54
|
2 |
|
public function getAnnotations() |
|
55
|
|
|
{ |
|
56
|
2 |
|
$annotations = array(); |
|
57
|
|
|
|
|
58
|
2 |
|
$this->step->isManual() && $annotations[] = self::CHAR_MANUAL; |
|
59
|
|
|
|
|
60
|
2 |
|
return $annotations; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* @return \Ktomk\Pipelines\File\Image |
|
65
|
|
|
*/ |
|
66
|
1 |
|
public function getImage() |
|
67
|
|
|
{ |
|
68
|
1 |
|
return $this->step->getImage(); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* @return string |
|
73
|
|
|
*/ |
|
74
|
1 |
|
public function getImageName() |
|
75
|
|
|
{ |
|
76
|
1 |
|
return $this->step->getImage()->getName(); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* @return string |
|
81
|
|
|
*/ |
|
82
|
2 |
|
public function getName() |
|
83
|
|
|
{ |
|
84
|
2 |
|
$name = $this->step->getName(); |
|
85
|
|
|
|
|
86
|
2 |
|
return null === $name ? self::NO_NAME : sprintf('"%s"', $name); |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
1 |
|
public function getStep() |
|
90
|
|
|
{ |
|
91
|
1 |
|
return $this->step; |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* @return int |
|
96
|
|
|
*/ |
|
97
|
1 |
|
public function getStepNumber() |
|
98
|
|
|
{ |
|
99
|
1 |
|
return $this->index + 1; |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* @return bool |
|
104
|
|
|
*/ |
|
105
|
1 |
|
public function hasDefaultImage() |
|
106
|
|
|
{ |
|
107
|
1 |
|
return File::DEFAULT_IMAGE === $this->getImageName(); |
|
108
|
|
|
} |
|
109
|
|
|
} |
|
110
|
|
|
|