/
IsValidLogLevel.php
71 lines (63 loc) · 1.65 KB
/
IsValidLogLevel.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
<?php
/**
* @author stev leibelt <artodeto@bazzline.net>
* @since 2013-08-30
*/
namespace Net\Bazzline\Component\ProxyLogger\Validator;
use Psr\Log\LogLevel;
use Net\Bazzline\Component\ProxyLogger\Exception\RuntimeException;
use Net\Bazzline\Component\Requirement\IsMetInterface;
/**
* Class IsValidLogLevel
*
* @package Net\Bazzline\Component\ProxyLogger\Validator
* @author stev leibelt <artodeto@bazzline.net>
* @since 2013-08-26
*/
class IsValidLogLevel implements IsMetInterface
{
/**
* @var mixed
* @author stev leibelt <artodeto@bazzline.net>
* @since 2013-08-28
*/
protected $logLevel;
/**
* @param mixed $logLevel
* @return $this
* @author stev leibelt <artodeto@bazzline.net>
* @since 2013-08-26
*/
public function setLogLevel($logLevel)
{
$this->logLevel = $logLevel;
return $this;
}
/**
* Validates if given requirement is met
*
* @return boolean
* @throws RuntimeException
* @author stev leibelt <artodeto@bazzline.net>
* @since 2013-06-25
*/
public function isMet()
{
$validLogLevels = array(
LogLevel::ALERT => true,
LogLevel::CRITICAL => true,
LogLevel::DEBUG => true,
LogLevel::EMERGENCY => true,
LogLevel::ERROR => true,
LogLevel::INFO => true,
LogLevel::NOTICE => true,
LogLevel::WARNING => true
);
if (is_null($this->logLevel)) {
throw new RuntimeException(
'no log logLevel provided'
);
}
return (isset($validLogLevels[$this->logLevel]));
}
}