-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStatus.php
79 lines (68 loc) · 1.39 KB
/
Status.php
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
69
70
71
72
73
74
75
76
77
78
79
<?php
namespace Imunew\Pipeline\Context;
/**
* Class Status
* @package Imunew\Pipeline
* @phpstan-consistent-constructor
*/
class Status implements StatusInterface
{
/** @var string */
private static $INITIALIZED = 'initialized';
/** @var string */
private static $STARTED = 'started';
/** @var string */
private static $STOPPED = 'stopped';
/** @var string */
private $status;
/**
* Status constructor.
* @param string $status
*/
private function __construct($status)
{
$this->status = $status;
}
/**
* @return StatusInterface
*/
public static function initialize()
{
return new static(self::$INITIALIZED);
}
/**
* @return StatusInterface
*/
public static function start()
{
return new static(self::$STARTED);
}
/**
* @return StatusInterface
*/
public static function stop()
{
return new static(self::$STOPPED);
}
/**
* @return bool
*/
public function isInitialized()
{
return in_array($this->status, [self::$INITIALIZED]);
}
/**
* @return bool
*/
public function isStarted()
{
return in_array($this->status, [self::$STARTED]);
}
/**
* @return bool
*/
public function isStopped()
{
return in_array($this->status, [self::$STOPPED]);
}
}