| Conditions | 9 |
| Paths | 7 |
| Total Lines | 45 |
| Code Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 14 | private function getEntityColumnCheck($property) |
||
|
|
|||
| 15 | { |
||
| 16 | // 設定されていなくても例外的にOKとするメソッド |
||
| 17 | $exceptOkProperties = [ |
||
| 18 | 'entityColumnCheckAllowField', |
||
| 19 | '_method', |
||
| 20 | ]; |
||
| 21 | // フィールド許可用のメソッドは対象外とする |
||
| 22 | if (in_array($property, $exceptOkProperties, true)) { |
||
| 23 | return; |
||
| 24 | } |
||
| 25 | |||
| 26 | // 新規の場合はチェックしない |
||
| 27 | if ($this->isNew()) { |
||
| 28 | return; |
||
| 29 | } |
||
| 30 | |||
| 31 | // プロパティに値がいる場合はOK |
||
| 32 | if (array_key_exists($property, $this->_properties)) { |
||
| 33 | return; |
||
| 34 | } |
||
| 35 | |||
| 36 | // プロパティが設定されている場合はOK |
||
| 37 | if (property_exists($this, $property)) { |
||
| 38 | return; |
||
| 39 | } |
||
| 40 | |||
| 41 | // getterがセットされている場合はOK |
||
| 42 | $snakeMethod = '_get' . Inflector::underscore($property); |
||
| 43 | $titleMethod = '_get' . ucfirst($property); |
||
| 44 | if ( |
||
| 45 | method_exists($this, $snakeMethod ) || |
||
| 46 | method_exists($this, $titleMethod ) |
||
| 47 | ) { |
||
| 48 | return; |
||
| 49 | } |
||
| 50 | |||
| 51 | // entityColumnCheckAllowFieldに値がセットされている場合はOKとする |
||
| 52 | if (is_array($this->entityColumnCheckAllowField) && in_array($property, $this->entityColumnCheckAllowField)) { |
||
| 53 | return; |
||
| 54 | } |
||
| 55 | |||
| 56 | // 上記条件に当てはまらない場合はException |
||
| 57 | throw new InternalErrorException('invalid entity(' . get_class($this) . ') paramater(' . $property . ')'); |
||
| 58 | } |
||
| 59 | } |
||
| 60 |