AbstractValidator::setHaystack()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * The Imaging Source Download System PHP Wrapper
6
 *
7
 * PHP wrapper for The Imaging Source Download System Web API. Authored and supported by The Imaging Source Europe GmbH.
8
 *
9
 * @link      http://dl-gui.theimagingsource.com to learn more about The Imaging Source Download System
10
 * @link      https://github.com/jonathanmaron/theimagingsource-tisd-sdk for the canonical source repository
11
 * @license   https://github.com/jonathanmaron/theimagingsource-tisd-sdk/blob/master/LICENSE.md
12
 * @copyright © 2022 The Imaging Source Europe GmbH
13
 */
14
15
namespace Tisd\Sdk\Validator;
16
17
class AbstractValidator
18
{
19
    /**
20
     * Array of valid strings
21
     *
22
     * @var array
23
     */
24
    protected array $haystack = [];
25
26
    /**
27
     * Return true, if $value is valid. False otherwise.
28
     *
29
     * @param string $value
30
     *
31
     * @return bool
32
     */
33 4
    public function isValid(string $value): bool
34
    {
35 4
        return in_array($value, $this->getHaystack(), true);
36
    }
37
38
    /**
39
     * Get the array of valid strings
40
     *
41
     * @return array
42
     */
43 4
    protected function getHaystack(): array
44
    {
45 4
        return $this->haystack;
46
    }
47
48
    /**
49
     * Set the array of valid strings
50
     *
51
     * @param array $haystack
52
     *
53
     * @return $this
54
     */
55 4
    protected function setHaystack(array $haystack): self
56
    {
57 4
        $this->haystack = $haystack;
58
59 4
        return $this;
60
    }
61
}
62