Job::getPackage()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * Job.php
4
 *
5
 * @copyright      More in license.md
6
 * @license        https://www.ipublikuj.eu
7
 * @author         Adam Kadlec <[email protected]>
8
 * @package        iPublikuj:Packages!
9
 * @subpackage     DependencyResolver
10
 * @since          2.0.0
11
 *
12
 * @date           27.06.16
13
 */
14
15
declare(strict_types = 1);
16
17
namespace IPub\Packages\DependencyResolver;
18
19
use IPub\Packages\Entities;
20
use IPub\Packages\Exceptions;
21
22
/**
23
 * Dependency solver job definition
24
 *
25
 * @package        iPublikuj:Packages!
26
 * @subpackage     DependencyResolver
27
 *
28
 * @author         Josef Kříž <[email protected]>
29
 * @author         Adam Kadlec <[email protected]>
30
 */
31
class Job
32
{
33
	/**
34
	 * Define actions
35
	 */
36
	public const ACTION_ENABLE = 'enable';
37
	public const ACTION_DISABLE = 'disable';
38
39
	/**
40
	 * List of available statuses
41
	 */
42
	const ACTIONS = [
43
		self::ACTION_ENABLE,
44
		self::ACTION_DISABLE,
45
	];
46
47
	/**
48
	 * @var string
49
	 */
50
	private $action;
51
52
	/**
53
	 * @var Entities\IPackage
54
	 */
55
	private $package;
56
57
	/**
58
	 * @param string $action
59
	 * @param Entities\IPackage $package
60
	 *
61
	 * @throws Exceptions\InvalidJobActionException
62
	 */
63
	public function __construct(string $action, Entities\IPackage $package)
64
	{
65
		if (!in_array($action, self::ACTIONS, TRUE)) {
66
			throw new Exceptions\InvalidJobActionException(sprintf(
67
				'Action must be one of "%s". "%s" is given.',
68
				join(', ', self::ACTIONS),
69
				$action
70
			));
71
		}
72
73
		$this->action = $action;
74
		$this->package = $package;
75
	}
76
77
	/**
78
	 * @return string
79
	 */
80
	public function getAction() : string
81
	{
82
		return $this->action;
83
	}
84
85
	/**
86
	 * @return Entities\IPackage
87
	 */
88
	public function getPackage() : Entities\IPackage
89
	{
90
		return $this->package;
91
	}
92
}
93