| Total Complexity | 9 | 
| Total Lines | 65 | 
| Duplicated Lines | 0 % | 
| Coverage | 73.91% | 
| Changes | 2 | ||
| Bugs | 0 | Features | 0 | 
| 1 | <?php | ||
| 9 | trait TableStructureRecordsTrait | ||
| 10 | { | ||
| 11 | protected $tableStructure = null; | ||
| 12 | |||
| 13 | /** | ||
| 14 | * @var null|array | ||
| 15 | */ | ||
| 16 | protected $fields = null; | ||
| 17 | |||
| 18 | /** | ||
| 19 | * @return null | ||
| 20 | */ | ||
| 21 | 1 | public function getFields() | |
| 22 |     { | ||
| 23 | 1 | $this->checkFieldsIsInitiated(); | |
| 24 | |||
| 25 | 1 | return $this->fields; | |
|  | |||
| 26 | } | ||
| 27 | |||
| 28 | 1 | protected function checkFieldsIsInitiated() | |
| 29 |     { | ||
| 30 | 1 |         if ($this->fields === null) { | |
| 31 | 1 | $this->initFields(); | |
| 32 | } | ||
| 33 | 1 | } | |
| 34 | |||
| 35 | 1 | public function initFields() | |
| 36 |     { | ||
| 37 | 1 | $structure = $this->getTableStructure(); | |
| 38 | 1 | $this->fields = array_keys($structure['fields']); | |
| 39 | 1 | } | |
| 40 | |||
| 41 | /** | ||
| 42 | * @param string $name | ||
| 43 | * @return bool | ||
| 44 | */ | ||
| 45 | public function hasField(string $name) | ||
| 46 |     { | ||
| 47 | $this->checkFieldsIsInitiated(); | ||
| 48 | return isset($this->fields[$name]); | ||
| 49 | } | ||
| 50 | |||
| 51 | /** | ||
| 52 | * @return mixed | ||
| 53 | */ | ||
| 54 | 4 | protected function getTableStructure() | |
| 61 | } | ||
| 62 | |||
| 63 | /** | ||
| 64 | * @param null $tableStructure | ||
| 65 | */ | ||
| 66 | 5 | public function setTableStructure($tableStructure) | |
| 67 |     { | ||
| 68 | 5 | $this->tableStructure = $tableStructure; | |
| 69 | 5 | } | |
| 70 | |||
| 71 | protected function initTableStructure() | ||
| 74 | } | ||
| 75 | } | ||
| 76 |