1 | <?php |
||
15 | class CallableAction implements ActionInterface |
||
16 | { |
||
17 | |||
18 | /** @var JobInterface */ |
||
19 | private $job; |
||
20 | |||
21 | /** @var DateTimeInterface */ |
||
22 | private $time; |
||
23 | |||
24 | /** @var integer */ |
||
25 | private $state; |
||
26 | |||
27 | /** @var mixed */ |
||
28 | private $report; |
||
29 | |||
30 | /** |
||
31 | * @return mixed|void |
||
32 | */ |
||
33 | 7 | public function __invoke() |
|
40 | |||
41 | /** |
||
42 | * AbstractTask constructor. |
||
43 | * @param JobInterface $job - job related to action |
||
44 | * @param DateTimeInterface $time - time of occurrence (note: this it not time of execution) |
||
45 | */ |
||
46 | 22 | public function __construct(JobInterface $job, DateTimeInterface $time) |
|
52 | |||
53 | /** |
||
54 | * @inheritdoc |
||
55 | */ |
||
56 | 11 | public function getTime() |
|
60 | |||
61 | /** |
||
62 | * @inheritdoc |
||
63 | */ |
||
64 | 10 | public function getJob() |
|
68 | |||
69 | /** |
||
70 | * @return mixed|void |
||
71 | */ |
||
72 | 5 | public function getId() |
|
73 | { |
||
74 | 5 | return $this->getTime()->getTimestamp().md5(implode('_', [ |
|
75 | 5 | $this->getTime()->getTimestamp(), |
|
76 | 5 | $this->getJob()->getRRule()->getStartDate()->getTimestamp(), |
|
77 | 5 | $this->getJob()->getRRule()->getRrule(), |
|
78 | 5 | $this->hashCallable($this->getJob()->getCallable()) |
|
79 | 5 | ])); |
|
80 | } |
||
81 | |||
82 | /** |
||
83 | * @inheritdoc |
||
84 | */ |
||
85 | 4 | public function getState() |
|
89 | |||
90 | /** |
||
91 | * @inheritdoc |
||
92 | */ |
||
93 | 5 | public function getReport() |
|
100 | |||
101 | /** |
||
102 | * Get unique hash from callable |
||
103 | * @param $callable |
||
104 | * @return string |
||
105 | */ |
||
106 | 5 | private function hashCallable($callable) |
|
123 | } |