ErrorMessagesBase::errorMessage()   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
namespace InputGuard\Guards;
5
6
trait ErrorMessagesBase
7
{
8
    /**
9
     * @var array
10
     */
11
    private $errorMessages = [];
12
13
    abstract public function success(): bool;
14
15
    /**
16
     * @param string $message
17
     *
18
     * @return $this
19
     */
20 11
    public function errorMessage(string $message): self
21
    {
22 11
        $this->errorMessages[] = $message;
23
24 11
        return $this;
25
    }
26
27 10
    public function pullErrorMessages(): array
28
    {
29 10
        $this->success();
30
31 10
        return $this->errorMessages;
32
    }
33
}
34