Conditions | 3 |
Paths | 2 |
Total Lines | 34 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Tests | 17 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
20 | 24 | protected function ObtainLastLeafInTree() : DaftNestedWriteableObject |
|
21 | { |
||
22 | /** |
||
23 | * @var \ParagonIE\EasyDB\EasyDB |
||
24 | */ |
||
25 | 24 | $db = $this->db; |
|
26 | |||
27 | /** |
||
28 | * @psalm-var class-string<T> |
||
29 | */ |
||
30 | 24 | $type = $this->type; |
|
31 | |||
32 | 24 | $sth = $db->prepare( |
|
33 | 'SELECT ' . |
||
34 | 24 | implode(',', array_map( |
|
35 | 24 | [$db, 'escapeIdentifier'], |
|
36 | 24 | $type::DaftObjectIdProperties() |
|
37 | )) . |
||
38 | 24 | ' FROM ' . |
|
39 | 24 | $this->DaftObjectDatabaseTable() . |
|
|
|||
40 | 24 | ' ORDER BY ' . |
|
41 | 24 | $db->escapeIdentifier('intNestedLeft') . |
|
42 | 24 | ' DESC LIMIT 1' |
|
43 | ); |
||
44 | |||
45 | 24 | $sth->execute(); |
|
46 | |||
47 | 24 | $res = $sth->fetch(PDO::FETCH_ASSOC); |
|
48 | |||
49 | 24 | if (1 === count($res) && ! is_a($type, DefinesOwnArrayIdInterface::class, true)) { |
|
50 | 24 | $res = current($res); |
|
51 | } |
||
52 | |||
53 | 24 | return $this->RecallDaftObjectOrThrow($res); |
|
54 | } |
||
56 |