Total Complexity | 9 |
Total Lines | 50 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
11 | class Voucher implements Rule |
||
12 | { |
||
13 | protected $isInvalid = false; |
||
14 | protected $isExpired = false; |
||
15 | protected $wasRedeemed = false; |
||
16 | |||
17 | /** |
||
18 | * Determine if the validation rule passes. |
||
19 | * |
||
20 | * @param string $attribute |
||
21 | * @param mixed $value |
||
22 | * @return bool |
||
23 | */ |
||
24 | public function passes($attribute, $value) |
||
25 | { |
||
26 | try { |
||
27 | $voucher = Vouchers::check($value); |
||
28 | |||
29 | // Check if the voucher was already redeemed |
||
30 | if (auth()->check() && $voucher->users()->wherePivot('user_id', auth()->id())->exists()) { |
||
31 | throw VoucherAlreadyRedeemed::create($voucher); |
||
32 | } |
||
33 | } catch (VoucherIsInvalid $exception) { |
||
34 | $this->isInvalid = true; |
||
35 | return false; |
||
36 | } catch (VoucherExpired $exception) { |
||
37 | $this->isExpired = true; |
||
38 | return false; |
||
39 | } catch (VoucherAlreadyRedeemed $exception) { |
||
40 | $this->wasRedeemed = true; |
||
41 | return false; |
||
42 | } |
||
43 | |||
44 | return true; |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * Get the validation error message. |
||
49 | * |
||
50 | * @return string |
||
51 | */ |
||
52 | public function message() |
||
61 | } |
||
62 | } |
||
63 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths