Completed
Push — master ( da5b20...773556 )
by Kamil
03:06
created

FlagResolverAbstract   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 0
dl 0
loc 38
ccs 0
cts 19
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
getFlags() 0 1 ?
getMapping() 0 1 ?
B resolve() 0 22 5
1
<?php
2
3
namespace Dazzle\Filesystem\Driver\Flag;
4
5
abstract class FlagResolverAbstract
6
{
7
    /**
8
     * @return int
9
     */
10
    abstract protected function getFlags();
11
12
    /**
13
     * @return array
14
     */
15
    abstract protected function getMapping();
16
17
    /**
18
     * @see FlagResolverInterface::resolve
19
     */
20
    public function resolve($flagString, $flags = null, $mapping = null)
21
    {
22
        if ($flags === null)
23
        {
24
            $flags = $this->getFlags();
25
        }
26
27
        if ($mapping === null)
28
        {
29
            $mapping = $this->getMapping();
30
        }
31
32
        foreach (str_split($flagString) as $flag)
33
        {
34
            if (isset($mapping[$flag]))
35
            {
36
                $flags |= $mapping[$flag];
37
            }
38
        }
39
40
        return $flags;
41
    }
42
}
43