CrudDeleteAction::execute()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
ccs 4
cts 4
cp 1
crap 1
1
<?php
2
/**
3
 * Copyright 2016 - 2018, Cake Development Corporation (http://cakedc.com)
4
 *
5
 * Licensed under The MIT License
6
 * Redistributions of files must retain the above copyright notice.
7
 *
8
 * @copyright Copyright 2016 - 2018, Cake Development Corporation (http://cakedc.com)
9
 * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
10
 */
11
12
namespace CakeDC\Api\Service\Action;
13
14
/**
15
 * Class CrudDeleteAction
16
 *
17
 * @package CakeDC\Api\Service\Action
18
 */
19
class CrudDeleteAction extends CrudAction
20
{
21
22
    /**
23
     * Execute action.
24
     *
25
     * @return mixed
26
     */
27 4
    public function execute()
28
    {
29 4
        $record = $this->_getEntity($this->_id);
30 3
        $result = $this->getTable()->delete($record);
0 ignored issues
show
Documentation introduced by
$record is of type object<Cake\Collection\Collection>, but the function expects a object<Cake\Datasource\EntityInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
31
32 3
        return $result;
33
    }
34
}
35