1 | <?php |
||
10 | class ExpressionBuilder implements ExpressionBuilderInterface |
||
11 | { |
||
12 | /** @var TaskBag */ |
||
13 | protected $bag; |
||
14 | |||
15 | /** |
||
16 | * Builds an expression from the TaskBag |
||
17 | * @param TaskBag|null $bag |
||
18 | * @return CronExpression |
||
19 | */ |
||
20 | 12 | public function build(TaskBag $bag = null) |
|
56 | |||
57 | /** |
||
58 | * Builds expression from a string expression |
||
59 | * @param null|string $string |
||
60 | * @return CronExpression |
||
61 | */ |
||
62 | 13 | public function buildFrom($string) |
|
66 | |||
67 | /** |
||
68 | * Set the Task Bag |
||
69 | * @param TaskBag $bag |
||
70 | * @return $this |
||
71 | */ |
||
72 | 12 | public function setTaskBag(TaskBag $bag) |
|
77 | |||
78 | /** |
||
79 | * @return TaskBag |
||
80 | */ |
||
81 | public function getTaskBag() |
||
85 | |||
86 | /** |
||
87 | * Is only the interval set in the bag? |
||
88 | * @param TaskBag $bag |
||
89 | * @return bool |
||
90 | */ |
||
91 | 12 | protected function onlyIntervalIsSet(TaskBag $bag) |
|
92 | { |
||
93 | 12 | return $bag->getInterval() !== null |
|
94 | 12 | && $bag->getMonth() === null |
|
95 | 12 | && $bag->getDay() === null |
|
96 | 12 | && $bag->getMinute() === null |
|
97 | 12 | && $bag->getHour() === null; |
|
98 | } |
||
99 | |||
100 | /** |
||
101 | * Ensures the parts are cast as strings |
||
102 | * @param $value |
||
103 | * @return string |
||
104 | */ |
||
105 | 10 | protected function toPart($value) |
|
113 | |||
114 | /** |
||
115 | * Returns the part from the bag with * as default |
||
116 | * @param string $part |
||
117 | * @return string |
||
118 | */ |
||
119 | 10 | protected function getPartWithDefault($part) |
|
128 | } |
||
129 |