| Conditions | 5 |
| Paths | 12 |
| Total Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | public function handle($request, Closure $next) |
||
| 12 | { |
||
| 13 | if (! $request->hasValidSignature()) { |
||
| 14 | abort(Response::HTTP_FORBIDDEN, 'The welcome link does not have a valid signature or is expired.'); |
||
| 15 | } |
||
| 16 | |||
| 17 | if (! $request->user) { |
||
| 18 | abort(Response::HTTP_FORBIDDEN, 'Could not find a user to be welcomed.'); |
||
| 19 | } |
||
| 20 | |||
| 21 | if (is_null($request->user->welcome_valid_until)) { |
||
| 22 | return abort(Response::HTTP_FORBIDDEN, 'The welcome link has already been used.'); |
||
| 23 | } |
||
| 24 | |||
| 25 | if (Carbon::create($request->user->welcome_valid_until)->isPast()) { |
||
|
|
|||
| 26 | return abort(Response::HTTP_FORBIDDEN, 'The welcome link has expired.'); |
||
| 27 | } |
||
| 28 | |||
| 29 | return $next($request); |
||
| 30 | } |
||
| 31 | } |
||
| 32 |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idableprovides a methodequalsIdthat in turn relies on the methodgetId(). If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()as an abstract method to the trait will make sure it is available.