CaptureAggregator::remember()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 1
1
<?php declare(strict_types=1);
2
3
namespace Limoncello\Validation\Captures;
4
5
/**
6
 * Copyright 2015-2020 [email protected]
7
 *
8
 * Licensed under the Apache License, Version 2.0 (the "License");
9
 * you may not use this file except in compliance with the License.
10
 * You may obtain a copy of the License at
11
 *
12
 * http://www.apache.org/licenses/LICENSE-2.0
13
 *
14
 * Unless required by applicable law or agreed to in writing, software
15
 * distributed under the License is distributed on an "AS IS" BASIS,
16
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
 * See the License for the specific language governing permissions and
18
 * limitations under the License.
19
 */
20
21
use Limoncello\Validation\Contracts\Captures\CaptureAggregatorInterface;
22
use function count;
23
24
/**
25
 * @package Limoncello\Validation
26
 */
27
class CaptureAggregator implements CaptureAggregatorInterface
28
{
29
    /**
30
     * @var array
31
     */
32
    private $remembered;
33
34
    /**
35
     * Constructor.
36
     */
37 21
    public function __construct()
38
    {
39 21
        $this->clear();
40
    }
41
42
    /**
43
     * @inheritdoc
44
     */
45 18
    public function remember(string $key, $value): CaptureAggregatorInterface
46
    {
47 18
        $this->remembered[$key] = $value;
48
49 18
        return $this;
50
    }
51
52
    /**
53
     * @inheritdoc
54
     */
55 16
    public function get(): array
56
    {
57 16
        return $this->remembered;
58
    }
59
60
    /**
61
     * @inheritdoc
62
     */
63 9
    public function count()
64
    {
65 9
        return count($this->get());
66
    }
67
68
    /**
69
     * @inheritdoc
70
     */
71 21
    public function clear(): CaptureAggregatorInterface
72
    {
73 21
        $this->remembered = [];
74
75 21
        return $this;
76
    }
77
}
78