| Total Complexity | 10 |
| Total Lines | 60 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | abstract class Methods implements MethodDefinitions |
||
| 13 | { |
||
| 14 | |||
| 15 | /** |
||
| 16 | * Import data from json string |
||
| 17 | * |
||
| 18 | * @param $data \stdClass |
||
| 19 | * @return bool |
||
| 20 | */ |
||
| 21 | final public function import(\stdClass $data) |
||
| 22 | { |
||
| 23 | foreach ($data as $key => $value) { |
||
| 24 | $this->$key = $value; |
||
| 25 | } |
||
| 26 | |||
| 27 | return $this->isValid(); |
||
| 28 | } |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Validate properties |
||
| 32 | * @return bool |
||
| 33 | */ |
||
| 34 | final protected function isValid(): bool |
||
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * Export data |
||
| 51 | * @return bool|Methods |
||
| 52 | * @internal param Methods $data |
||
| 53 | * @internal param Methods $method |
||
| 54 | */ |
||
| 55 | final public function export() |
||
| 56 | { |
||
| 57 | |||
| 58 | foreach ($this as $key => $value) { |
||
| 59 | $this->$key = $value; |
||
| 60 | } |
||
| 61 | |||
| 62 | return $this->isValid() ? $this : false; |
||
| 63 | } |
||
| 64 | |||
| 65 | /** |
||
| 66 | * Convert method name to api |
||
| 67 | * @return string |
||
| 68 | */ |
||
| 69 | final public function getMethodName(): string |
||
| 72 | } |
||
| 73 | } |
||
| 74 |