StringGranter::isGranted()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 5
c 1
b 0
f 0
nc 3
nop 2
dl 0
loc 11
ccs 6
cts 6
cp 1
crap 3
rs 10
1
<?php
2
/**
3
 * This file is part of the sauls/security package.
4
 *
5
 * @author    Saulius Vaičeliūnas <[email protected]>
6
 * @link      http://saulius.vaiceliunas.lt
7
 * @copyright 2017
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
namespace Sauls\Bundle\Components\Component\Security\Access\Granter\String;
14
15
use Sauls\Bundle\Components\Component\Security\Access\Granter\BaseArrayGranter;
16
17
class StringGranter extends BaseArrayGranter implements StringGranterInterface
18
{
19
    /**
20
     * @param string $value
21
     * @param array  $values
22
     *
23
     * @return bool
24
     */
25 8
    public function isGranted(string $value, array $values = []): bool
26
    {
27 8
        $this->values = $this->mergeValues($values);
28
29 8
        foreach ($this->values as $part) {
30 8
            if (false !== stripos($value, $part)) {
31 6
                return true;
32
            }
33
        }
34
35 2
        return false;
36
    }
37
}
38