1 | <?php |
||
12 | class AssetOperation |
||
13 | { |
||
14 | const ADD = 'add'; |
||
15 | const REMOVE = 'remove'; |
||
16 | |||
17 | /** |
||
18 | * @var string |
||
19 | */ |
||
20 | private $operation; |
||
21 | /** |
||
22 | * @var Asset |
||
23 | */ |
||
24 | private $asset; |
||
25 | |||
26 | /** |
||
27 | * @param string $operation Either "add" or "remove" |
||
28 | * @param Asset $asset |
||
29 | * @throws InvalidArgumentException |
||
30 | */ |
||
31 | public function __construct(string $operation, Asset $asset) |
||
39 | |||
40 | /** |
||
41 | * @return string |
||
42 | */ |
||
43 | public function getOperation(): string |
||
47 | |||
48 | /** |
||
49 | * @return Asset |
||
50 | */ |
||
51 | public function getAsset(): Asset |
||
55 | |||
56 | /** |
||
57 | * Builds the AssetOperation from a simple string. |
||
58 | * |
||
59 | * @param string $value |
||
60 | * @param string $package |
||
61 | * @return AssetOperation |
||
62 | */ |
||
63 | public static function buildFromString(string $value, string $package, string $packageDir) : AssetOperation |
||
67 | |||
68 | /** |
||
69 | * Builds the AssetOperation from an array. |
||
70 | * |
||
71 | * @param array $array |
||
72 | * @param string $package |
||
73 | * @return AssetOperation |
||
74 | * @throws JsonException |
||
75 | */ |
||
76 | public static function buildFromArray(array $array, string $package, string $packageDir) : AssetOperation |
||
104 | } |
||
105 |