StringGranter   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 19
ccs 6
cts 6
cp 1
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A isGranted() 0 11 3
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