| Total Complexity | 9 |
| Total Lines | 86 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | abstract class Orm implements RepositoryInterface |
||
| 17 | { |
||
| 18 | use SingletonTrait { |
||
| 19 | __construct as finalConstruct; |
||
| 20 | } |
||
| 21 | |||
| 22 | use OrderTrait; |
||
| 23 | use DebugTrait; |
||
| 24 | use ReadTrait; |
||
| 25 | use WriteTrait; |
||
| 26 | |||
| 27 | /** @var Connection */ |
||
| 28 | protected static $conn; |
||
| 29 | |||
| 30 | /** @var string */ |
||
| 31 | protected $table; |
||
| 32 | |||
| 33 | /** @var Model */ |
||
| 34 | protected $model; |
||
| 35 | |||
| 36 | /** @var Select */ |
||
| 37 | protected $query; |
||
| 38 | |||
| 39 | public function __construct() |
||
| 42 | } |
||
| 43 | |||
| 44 | /** @return Orm */ |
||
| 45 | protected function orm() |
||
| 48 | } |
||
| 49 | |||
| 50 | /** @return Select */ |
||
| 51 | protected function getQuery() |
||
| 52 | { |
||
| 53 | return $this->query; |
||
| 54 | } |
||
| 55 | |||
| 56 | /** @param Connection $conn */ |
||
| 57 | public static function setConnection(Connection $conn) |
||
| 58 | { |
||
| 59 | static::$conn = $conn; |
||
| 60 | } |
||
| 61 | |||
| 62 | /** @return Connection */ |
||
| 63 | public function getConnection() |
||
| 66 | } |
||
| 67 | |||
| 68 | /** |
||
| 69 | * @param Model $model |
||
| 70 | * @return mixed[] |
||
| 71 | */ |
||
| 72 | abstract public function mapRow($model); |
||
| 73 | |||
| 74 | /** |
||
| 75 | * @param mixed[] $row |
||
| 76 | * @return Model |
||
| 77 | */ |
||
| 78 | abstract public function mapModel($row); |
||
| 79 | |||
| 80 | /** @return mixed[] */ |
||
| 81 | public function getRowValues() |
||
| 82 | { |
||
| 83 | return $this->mapRow($this->getModel()); |
||
| 84 | } |
||
| 85 | |||
| 86 | /** @return string */ |
||
| 87 | public function getTable() |
||
| 88 | { |
||
| 89 | return $this->table; |
||
| 90 | } |
||
| 91 | |||
| 92 | /** @return Model */ |
||
| 93 | public function getModel() |
||
| 96 | } |
||
| 97 | |||
| 98 | /** @return bool */ |
||
| 99 | public function modelExists() |
||
| 100 | { |
||
| 104 |