Completed
Pull Request — master (#233)
by
unknown
02:51
created

ArrayGuesser   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 26
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A supports() 0 7 1
A transform() 0 4 1
A fake() 0 4 1
A getName() 0 4 1
1
<?php
2
3
namespace Knp\FriendlyContexts\Guesser;
4
5
6
use Doctrine\DBAL\Types\Type;
7
8
class ArrayGuesser extends AbstractGuesser implements GuesserInterface
9
{
10
    public function supports(array $mapping)
11
    {
12
        $mapping = array_merge([ 'type' => null ], $mapping);
13
14
        // TODO: support other Doctrine array types
0 ignored issues
show
Coding Style Best Practice introduced by
Comments for TODO tasks are often forgotten in the code; it might be better to use a dedicated issue tracker.
Loading history...
15
        return $mapping['type'] === Type::TARRAY;
16
    }
17
18
    public function transform($str, array $mapping)
19
    {
20
        return json_decode($str);
21
    }
22
23
    public function fake(array $mapping)
24
    {
25
        return ['foo' => 'bar'];
26
    }
27
28
    public function getName()
29
    {
30
        return 'array';
31
    }
32
33
}
34