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

ArrayGuesser::supports()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 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