| Conditions | 3 |
| Paths | 3 |
| Total Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php defined('SYSPATH') OR die('No direct script access.'); |
||
| 14 | 1 | public function validate(Jam_Validated $model, $attribute, $value) |
|
| 15 | { |
||
| 16 | 1 | $promo_code = $this->valid_promo_code($value, $model); |
|
|
|
|||
| 17 | |||
| 18 | 1 | if (! $promo_code) |
|
| 19 | { |
||
| 20 | 1 | $model->errors()->add('promo_code_text', 'invalid'); |
|
| 21 | } |
||
| 22 | 1 | elseif ($promo_code->is_expired()) |
|
| 23 | { |
||
| 24 | 1 | $model->errors()->add('promo_code_text', 'expired'); |
|
| 25 | } |
||
| 26 | else |
||
| 27 | { |
||
| 28 | 1 | $promo_code->validate_purchase($model); |
|
| 29 | } |
||
| 30 | 1 | } |
|
| 31 | |||
| 40 |
This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.
Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.