1 | <?php |
||
2 | |||
3 | /* |
||
4 | * This file is part of Laravel Ban. |
||
5 | * |
||
6 | * (c) Anton Komarev <[email protected]> |
||
7 | * |
||
8 | * For the full copyright and license information, please view the LICENSE |
||
9 | * file that was distributed with this source code. |
||
10 | */ |
||
11 | |||
12 | declare(strict_types=1); |
||
13 | |||
14 | namespace Cog\Laravel\Ban\Services; |
||
15 | |||
16 | use Cog\Contracts\Ban\Ban as BanContract; |
||
17 | use Cog\Contracts\Ban\Bannable as BannableContract; |
||
18 | use Cog\Contracts\Ban\BanService as BanServiceContract; |
||
19 | use Cog\Laravel\Ban\Models\Ban; |
||
20 | use Illuminate\Support\Carbon; |
||
21 | |||
22 | class BanService implements BanServiceContract |
||
23 | { |
||
24 | /** |
||
25 | * Ban entity. |
||
26 | * |
||
27 | * @param \Cog\Contracts\Ban\Bannable $bannable |
||
28 | * @param array $attributes |
||
29 | * @return \Cog\Contracts\Ban\Ban |
||
30 | */ |
||
31 | public function ban(BannableContract $bannable, array $attributes = []): BanContract |
||
32 | { |
||
33 | return $bannable->bans()->create($attributes); |
||
0 ignored issues
–
show
|
|||
34 | } |
||
35 | |||
36 | /** |
||
37 | * Unban entity. |
||
38 | * |
||
39 | * @param \Cog\Contracts\Ban\Bannable $bannable |
||
40 | * @return void |
||
41 | */ |
||
42 | public function unban(BannableContract $bannable): void |
||
43 | { |
||
44 | $bannable->bans->each(function ($ban) { |
||
0 ignored issues
–
show
|
|||
45 | $ban->delete(); |
||
46 | }); |
||
47 | } |
||
48 | |||
49 | /** |
||
50 | * Delete all expired Ban models. |
||
51 | * |
||
52 | * @return void |
||
53 | */ |
||
54 | public function deleteExpiredBans(): void |
||
55 | { |
||
56 | $bans = Ban::query() |
||
57 | ->where('expired_at', '<=', Carbon::now()->format('Y-m-d H:i:s')) |
||
58 | ->get(); |
||
59 | |||
60 | $bans->each(function ($ban) { |
||
61 | $ban->delete(); |
||
62 | }); |
||
63 | } |
||
64 | } |
||
65 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.