Dot::resolve()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 2
eloc 4
nc 2
nop 1
1
<?php
2
3
namespace Enzyme\Freckle;
4
5
use InvalidArgumentException;
6
7
class Dot
8
{
9
    public function get($collection, $path)
10
    {
11
        $dotter = $this->resolve($collection);
12
13
        if (null === $dotter) {
14
            $type = gettype($collection);
15
16
            throw new InvalidArgumentException(
17
                "Freckle doesn't know how to process the " .
18
                "collection of type [{$type}]"
19
            );
20
        }
21
22
        return $dotter->get($collection, $path);
23
    }
24
25
    protected function resolve($collection)
26
    {
27
        if (true === is_array($collection)) {
28
            return new ArrayDotCollection;
29
        }
30
31
        return null;
32
    }
33
}
34