Total Complexity | 5 |
Total Lines | 65 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
11 | class NoBeanFoundException extends TDBMException |
||
12 | { |
||
13 | |||
14 | /** |
||
15 | * @var string |
||
16 | */ |
||
17 | private $tableName; |
||
18 | |||
19 | /** |
||
20 | * @var string |
||
21 | */ |
||
22 | private $className; |
||
23 | |||
24 | /** |
||
25 | * @var string[] |
||
26 | */ |
||
27 | private $primaryKeys; |
||
28 | |||
29 | /** |
||
30 | * @param string $tableName |
||
31 | * @param string[] $primaryKeys |
||
32 | * @param string $className |
||
33 | * @param Exception $previous |
||
34 | * @return NoBeanFoundException |
||
35 | */ |
||
36 | public static function missPrimaryKeyRecord(string $tableName, array $primaryKeys, string $className, Exception $previous) : self |
||
37 | { |
||
38 | $primaryKeysStringified = implode(' and ', array_map(function ($key, $value) { |
||
39 | return "'".$key."' = ".$value; |
||
40 | }, array_keys($primaryKeys), $primaryKeys)); |
||
41 | $exception = new self("No result found for query on table '".$tableName."' for ".$primaryKeysStringified, 0, $previous); |
||
42 | $exception->tableName = $tableName; |
||
43 | $exception->primaryKeys = $primaryKeys; |
||
44 | $exception->className = $className; |
||
45 | |||
46 | return $exception; |
||
47 | } |
||
48 | |||
49 | public static function missFilterRecord(string $tableName) : self |
||
50 | { |
||
51 | return new self("No result found for query on table '".$tableName."'"); |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * @return string |
||
56 | */ |
||
57 | public function getTableName(): string |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * @return string |
||
64 | */ |
||
65 | public function getClassName(): string |
||
66 | { |
||
67 | return $this->className; |
||
68 | } |
||
69 | |||
70 | /** |
||
71 | * @return string[] |
||
72 | */ |
||
73 | public function getPrimaryKeys(): array |
||
76 | } |
||
77 | } |
||
78 |