Total Complexity | 5 |
Total Lines | 40 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
14 | class FormCommentDelete extends Model |
||
15 | { |
||
16 | private $_record; |
||
17 | private $_type; |
||
18 | |||
19 | /** |
||
20 | * FormCommentDelete constructor. Pass active record and type of comment system inside. |
||
21 | * @param CommentPost[]|CommentAnswer[]|Collection $record |
||
22 | * @param string $type |
||
23 | */ |
||
24 | public function __construct($record, $type) |
||
25 | { |
||
26 | $this->_record = $record; |
||
27 | $this->_type = $type; |
||
28 | parent::__construct(); |
||
29 | } |
||
30 | |||
31 | /** |
||
32 | * Make delete items after submit |
||
33 | */ |
||
34 | public function make() |
||
35 | { |
||
36 | // also delete all answers |
||
37 | if ($this->_type === 'comment') { |
||
38 | foreach ($this->getRecord() as $com) { |
||
39 | /** @var CommentPost $com */ |
||
40 | $com->answers()->delete(); |
||
41 | } |
||
42 | } |
||
43 | |||
44 | $this->_record->delete(); |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * Get records to delete as object |
||
49 | * @return CommentAnswer[]|CommentPost[]|Collection |
||
50 | */ |
||
51 | public function getRecord() |
||
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.