-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathElement.php
More file actions
68 lines (58 loc) · 1.45 KB
/
Element.php
File metadata and controls
68 lines (58 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
namespace Ezweb\Workflow\Elements;
abstract class Element implements \JsonSerializable
{
/**
* @param self[] $elements
* @return string
*/
protected function hash(array $elements)
{
$hashes = [];
foreach ($elements as $value) {
$hashes[] = $value->getHash();
}
sort($hashes, SORT_STRING);
return md5(static::getName() . '.' . implode('.', $hashes));
}
final public function jsonSerialize()
{
$data = $this->getJSONData();
// add object hash to json
$data['hash'] = $this->getHash();
return $data;
}
/**
* @return string
*/
abstract public static function getName(): string;
/**
* @return static
*/
abstract public static function create(): self;
/**
* @return string
*/
abstract public function getHash(): string;
/**
* @return array
*/
abstract public function getJSONData(): ?array;
/**
* @param mixed[] $vars
* @param array $childrenValues
* @return mixed
*/
abstract protected function getResult(array $vars, array $childrenValues);
/**
* @return string
*/
abstract public function __toString(): string;
/**
* Is this Element call valid?
* @param array $vars
* @param array $childrenValues
* @return bool
*/
abstract protected function isValid(array $vars, array $childrenValues): bool;
}