Passed
Push — master ( 54de5e...97aeae )
by Peter
02:25
created

Base64::getSlug()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AbterPhp\Framework\Validation\Rules;
6
7
use Opulence\Validation\Rules\IRule;
8
9
class Base64 implements IRule
10
{
11
    /**
12
     * @inheritdoc
13
     */
14
    public function getSlug(): string
15
    {
16
        return 'base64';
17
    }
18
19
    /**
20
     * @inheritdoc
21
     */
22
    public function passes($value, array $allValues = []): bool
23
    {
24
        $decoded = base64_decode($value, true);
25
26
        if (is_bool($decoded)) {
0 ignored issues
show
introduced by
The condition is_bool($decoded) is always false.
Loading history...
27
            return $decoded;
28
        }
29
30
        return true;
31
    }
32
}
33