| Total Complexity | 4 |
| Total Lines | 32 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 16 | class QuantityDto extends Model |
||
| 17 | { |
||
| 18 | public $unit; |
||
| 19 | |||
| 20 | public $quantity; |
||
| 21 | |||
| 22 | public function rules() |
||
| 23 | { |
||
| 24 | return [ |
||
| 25 | [['unit', 'quantity'], 'required'], |
||
| 26 | ['unit', 'string'], |
||
| 27 | ['quantity', 'number'], |
||
| 28 | ['unit', 'unitValidation'], |
||
| 29 | ]; |
||
| 30 | } |
||
| 31 | |||
| 32 | public function unitValidation() |
||
| 33 | { |
||
| 34 | try { |
||
| 35 | Quantity::create($this->unit, $this->quantity); |
||
| 36 | |||
| 37 | return true; |
||
| 38 | } catch (\Exception $exception) { |
||
| 39 | $this->addError('unit', $exception->getMessage()); |
||
| 40 | |||
| 41 | return false; |
||
| 42 | } |
||
| 43 | } |
||
| 44 | |||
| 45 | public function load($data, $formName = '') |
||
| 48 | } |
||
| 49 | } |
||
| 50 |