Conditions | 6 |
Paths | 4 |
Total Lines | 19 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 6 |
Changes | 0 |
1 | <?php |
||
42 | 9 | public function create($data = null) |
|
43 | { |
||
44 | 9 | if (! \is_array($data) && ! $data instanceof \ArrayAccess) { |
|
45 | 1 | return null; |
|
46 | } |
||
47 | |||
48 | // is the discriminator present |
||
49 | 8 | if (isset($data[$this->discriminator])) { |
|
50 | // get the value |
||
51 | 5 | $type = $data[$this->discriminator]; |
|
52 | |||
53 | // do we know how to map this one |
||
54 | 5 | if ($type !== null && isset($this->mapping[$type])) { |
|
55 | 4 | return $this->mapping[$type]->create($data); |
|
56 | } |
||
57 | } |
||
58 | |||
59 | // map to the default |
||
60 | 4 | return $this->defaultCreator->create($data); |
|
61 | } |
||
63 |