Lines
0.00%
0 / 24
Functions and Methods
0.00%
0 / 9
Classes and Traits
0.00%
0 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| PDOTrait | 0.00% | 0 / 24 | 0.00% | 0 / 9 | 272 | 0.00% | 0 / 1 | |||
| setPDOAccess | 0.00% | 0 / 2 | 0.00% | 0 / 1 | 2 | |||||
| getPDOAccess | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | |||||
| query | 0.00% | 0 / 3 | 0.00% | 0 / 1 | 6 | |||||
| exec | 0.00% | 0 / 3 | 0.00% | 0 / 1 | 6 | |||||
| prepare | 0.00% | 0 / 3 | 0.00% | 0 / 1 | 6 | |||||
| beginTransaction | 0.00% | 0 / 3 | 0.00% | 0 / 1 | 6 | |||||
| commit | 0.00% | 0 / 3 | 0.00% | 0 / 1 | 6 | |||||
| rollBack | 0.00% | 0 / 3 | 0.00% | 0 / 1 | 6 | |||||
| inTransaction | 0.00% | 0 / 3 | 0.00% | 0 / 1 | 6 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | namespace BO\Zmsdldb\Importer; | |
| 4 | ||
| 5 | use BO\Zmsdldb\PDOAccess; | |
| 6 | ||
| 7 | trait PDOTrait | |
| 8 | { | |
| 9 | protected mixed $pdoAccess; | |
| 10 | ||
| 11 | public function setPDOAccess(PDOAccess $pdoAccess): self | |
| 12 | { | |
| 13 | $this->pdoAccess = $pdoAccess; | |
| 14 | return $this; | |
| 15 | } | |
| 16 | ||
| 17 | public function getPDOAccess(): PDOAccess | |
| 18 | { | |
| 19 | return $this->pdoAccess; | |
| 20 | } | |
| 21 | ||
| 22 | /** | |
| 23 | * parameters see https://www.php.net/manual/de/pdo.query.php | |
| 24 | * @psalm-api | |
| 25 | */ | |
| 26 | public function query(mixed ...$args): mixed | |
| 27 | { | |
| 28 | try { | |
| 29 | return $this->getPDOAccess()->query(...$args); | |
| 30 | } catch (\Exception $e) { | |
| 31 | throw $e; | |
| 32 | } | |
| 33 | } | |
| 34 | ||
| 35 | /** | |
| 36 | * parameters see https://www.php.net/manual/de/pdo.exec.php | |
| 37 | * @psalm-api | |
| 38 | */ | |
| 39 | ||
| 40 | public function exec(mixed ...$args): mixed | |
| 41 | { | |
| 42 | try { | |
| 43 | return $this->getPDOAccess()->exec(...$args); | |
| 44 | } catch (\Exception $e) { | |
| 45 | throw $e; | |
| 46 | } | |
| 47 | } | |
| 48 | ||
| 49 | /** | |
| 50 | * parameters see https://www.php.net/manual/de/pdo.prepare.php | |
| 51 | * @psalm-api | |
| 52 | */ | |
| 53 | public function prepare(mixed ...$args): mixed | |
| 54 | { | |
| 55 | try { | |
| 56 | return $this->getPDOAccess()->prepare(...$args); | |
| 57 | } catch (\Exception $e) { | |
| 58 | throw $e; | |
| 59 | } | |
| 60 | } | |
| 61 | ||
| 62 | public function beginTransaction(): mixed | |
| 63 | { | |
| 64 | try { | |
| 65 | return $this->getPDOAccess()->beginTransaction(); | |
| 66 | } catch (\Exception $e) { | |
| 67 | throw $e; | |
| 68 | } | |
| 69 | } | |
| 70 | ||
| 71 | public function commit(): mixed | |
| 72 | { | |
| 73 | try { | |
| 74 | return $this->getPDOAccess()->commit(); | |
| 75 | } catch (\Exception $e) { | |
| 76 | throw $e; | |
| 77 | } | |
| 78 | } | |
| 79 | ||
| 80 | public function rollBack(): mixed | |
| 81 | { | |
| 82 | try { | |
| 83 | return $this->getPDOAccess()->rollBack(); | |
| 84 | } catch (\Exception $e) { | |
| 85 | throw $e; | |
| 86 | } | |
| 87 | } | |
| 88 | ||
| 89 | /** @psalm-api */ | |
| 90 | public function inTransaction(): mixed | |
| 91 | { | |
| 92 | try { | |
| 93 | return $this->getPDOAccess()->inTransaction(); | |
| 94 | } catch (\Exception $e) { | |
| 95 | throw $e; | |
| 96 | } | |
| 97 | } | |
| 98 | } |