| Conditions | 3 |
| Paths | 2 |
| Total Lines | 44 |
| Code Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 18 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 38 | 24 | protected function ObtainLastLeafInTree() : DaftNestedWriteableObject |
|
| 39 | { |
||
| 40 | /** |
||
| 41 | * @var \ParagonIE\EasyDB\EasyDB |
||
| 42 | */ |
||
| 43 | 24 | $db = $this->db; |
|
| 44 | |||
| 45 | /** |
||
| 46 | * @psalm-var class-string<T> |
||
| 47 | */ |
||
| 48 | 24 | $type = $this->type; |
|
| 49 | |||
| 50 | 24 | $sth = $db->prepare( |
|
| 51 | 'SELECT ' . |
||
| 52 | 24 | implode(',', array_map( |
|
| 53 | 24 | [$db, 'escapeIdentifier'], |
|
| 54 | 24 | $type::DaftObjectIdProperties() |
|
| 55 | )) . |
||
| 56 | 24 | ' FROM ' . |
|
| 57 | 24 | $this->DaftObjectDatabaseTable() . |
|
| 58 | 24 | ' ORDER BY ' . |
|
| 59 | 24 | $db->escapeIdentifier('intNestedLeft') . |
|
| 60 | 24 | ' DESC LIMIT 1' |
|
| 61 | ); |
||
| 62 | |||
| 63 | 24 | $sth->execute(); |
|
| 64 | |||
| 65 | /** |
||
| 66 | * @var array<string, scalar> |
||
| 67 | */ |
||
| 68 | 24 | $res = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 69 | |||
| 70 | 24 | if (1 === count($res) && ! is_a($type, DefinesOwnArrayIdInterface::class, true)) { |
|
| 71 | 24 | $res = current($res); |
|
| 72 | } |
||
| 73 | |||
| 74 | /** |
||
| 75 | * @var DaftNestedWriteableObject |
||
| 76 | * |
||
| 77 | * @psalm-var T |
||
| 78 | */ |
||
| 79 | 24 | $out = $this->RecallDaftObjectOrThrow($res); |
|
| 80 | |||
| 81 | 24 | return $out; |
|
|
|
|||
| 82 | } |
||
| 84 |