| Total Complexity | 8 |
| Total Lines | 80 |
| 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() |
||
| 46 | { |
||
| 47 | return $this; |
||
| 48 | } |
||
| 49 | |||
| 50 | /** @param Connection $conn */ |
||
| 51 | public static function setConnection(Connection $conn) |
||
| 52 | { |
||
| 53 | static::$conn = $conn; |
||
| 54 | } |
||
| 55 | |||
| 56 | /** @return Connection */ |
||
| 57 | public static function getConnection() |
||
| 60 | } |
||
| 61 | |||
| 62 | /** |
||
| 63 | * @param Model $model |
||
| 64 | * @return mixed[] |
||
| 65 | */ |
||
| 66 | abstract public function mapRow($model); |
||
| 67 | |||
| 68 | /** |
||
| 69 | * @param mixed[] $row |
||
| 70 | * @return Model |
||
| 71 | */ |
||
| 72 | abstract public function mapModel($row); |
||
| 73 | |||
| 74 | /** @return mixed[] */ |
||
| 75 | public function getRowValues() |
||
| 76 | { |
||
| 77 | return $this->mapRow($this->getModel()); |
||
| 78 | } |
||
| 79 | |||
| 80 | /** @return string */ |
||
| 81 | public function getTable() |
||
| 82 | { |
||
| 83 | return $this->table; |
||
| 84 | } |
||
| 85 | |||
| 86 | /** @return Model */ |
||
| 87 | public function getModel() |
||
| 90 | } |
||
| 91 | |||
| 92 | /** @return bool */ |
||
| 93 | public function modelExists() |
||
| 98 |