1 | <?php |
||
2 | |||
3 | namespace Apps\Model\Admin\Content; |
||
4 | |||
5 | use Apps\ActiveRecord\Content; |
||
6 | use Ffcms\Core\Arch\Model; |
||
7 | use Ffcms\Core\Helper\FileSystem\Directory; |
||
8 | use Illuminate\Database\Eloquent\Collection; |
||
9 | |||
10 | class FormContentClear extends Model |
||
11 | { |
||
12 | public $count = 0; |
||
13 | |||
14 | /** @var Content|Collection */ |
||
15 | private $_records; |
||
16 | |||
17 | /** |
||
18 | * FormContentClear constructor. Pass content records collection object inside (can be empty collection) |
||
19 | * @param Content|Collection $records |
||
20 | */ |
||
21 | public function __construct($records) |
||
22 | { |
||
23 | $this->_records = $records; |
||
24 | $this->count = $this->_records->count(); |
||
25 | parent::__construct(); |
||
26 | } |
||
27 | |||
28 | /** |
||
29 | * Form display labels |
||
30 | * @return array |
||
31 | */ |
||
32 | public function labels(): array |
||
33 | { |
||
34 | return [ |
||
35 | 'count' => __('Trashed content') |
||
36 | ]; |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * Finally delete content item |
||
41 | */ |
||
42 | public function make() |
||
43 | { |
||
44 | // remove gallery files if exists |
||
45 | foreach ($this->_records->get() as $record) { |
||
0 ignored issues
–
show
|
|||
46 | $galleryPath = '/upload/gallery/' . (int)$record->id; |
||
47 | if (Directory::exist($galleryPath)) { |
||
48 | Directory::remove($galleryPath); |
||
49 | } |
||
50 | } |
||
51 | |||
52 | // finally remove from db |
||
53 | $this->_records->forceDelete(); |
||
54 | } |
||
55 | } |
||
56 |
This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.