FailureMessages   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 44
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getErrorMessage() 0 3 1
A hasErrorMessage() 0 3 1
A getErrorMessages() 0 3 1
A __construct() 0 4 1
1
<?php
2
/**
3
 * Copyright (c) 2019. Volodymyr Hryvinskyi.  All rights reserved.
4
 * @author: <mailto:[email protected]>
5
 * @github: <https://github.com/hryvinskyi>
6
 */
7
8
declare(strict_types=1);
9
10
namespace Hryvinskyi\InvisibleCaptcha\Model\Provider;
11
12
use Hryvinskyi\Base\Helper\ArrayHelper;
13
14
/**
15
 * Class FailureMessages
16
 */
17
class FailureMessages
18
{
19
    /**
20
     * @var array
21
     */
22
    private $errorMessages;
23
24
    /**
25
     * AbstractFailure constructor.
26
     *
27
     * @param array $errorMessages
28
     */
29
    public function __construct(
30
        array $errorMessages = []
31
    ) {
32
        $this->errorMessages = $errorMessages;
33
    }
34
35
    /**
36
     * @return array
37
     */
38
    public function getErrorMessages(): array
39
    {
40
        return $this->errorMessages;
41
    }
42
43
    /**
44
     * @param string $key
45
     *
46
     * @return string|null
47
     */
48
    public function getErrorMessage(string $key): ?string
49
    {
50
        return ArrayHelper::getValue($this->getErrorMessages(), $key);
51
    }
52
53
    /**
54
     * @param string $key
55
     *
56
     * @return bool
57
     */
58
    public function hasErrorMessage(string $key): bool
59
    {
60
        return ArrayHelper::keyExists($key, $this->getErrorMessages());
61
    }
62
}
63