Passed
Pull Request — master (#4)
by Tim
04:21
created

EavAttributeGroupAction   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
eloc 5
dl 0
loc 45
ccs 0
cts 12
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 3 1
A update() 0 3 1
A persist() 0 8 1
1
<?php
2
3
/**
4
 * TechDivision\Import\Attribute\Set\Actions\EavAttributeGroupAction
5
 *
6
 * NOTICE OF LICENSE
7
 *
8
 * This source file is subject to the Open Software License (OSL 3.0)
9
 * that is available through the world-wide-web at this URL:
10
 * http://opensource.org/licenses/osl-3.0.php
11
 *
12
 * PHP version 5
13
 *
14
 * @author    Tim Wagner <[email protected]>
15
 * @copyright 2019 TechDivision GmbH <[email protected]>
16
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
 * @link      https://github.com/techdivision/import-attribute-set
18
 * @link      http://www.techdivision.com
19
 */
20
21
namespace TechDivision\Import\Attribute\Set\Actions;
22
23
use TechDivision\Import\Utils\EntityStatus;
24
use TechDivision\Import\Actions\AbstractAction;
25
26
/**
27
 * An action implementation that provides CRUD functionality for EAV attribute groups.
28
 *
29
 * @author    Tim Wagner <[email protected]>
30
 * @copyright 2019 TechDivision GmbH <[email protected]>
31
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
32
 * @link      https://github.com/techdivision/import-attribute-set
33
 * @link      http://www.techdivision.com
34
 */
35
class EavAttributeGroupAction extends AbstractAction implements EavAttributeGroupActionInterface
36
{
37
38
    /**
39
     * Helper method that create/update the passed entity, depending on
40
     * the entity's status.
41
     *
42
     * @param array $row The entity data to create/update
43
     *
44
     * @return string The last inserted ID
45
     */
46
    public function persist(array $row)
47
    {
48
49
        // load the method name
50
        $methodName = $row[EntityStatus::MEMBER_NAME];
51
52
        // invoke the method
53
        return $this->$methodName($row);
54
    }
55
56
    /**
57
     * Creates's the entity with the passed attributes.
58
     *
59
     * @param array       $row  The attributes of the entity to create
60
     * @param string|null $name The name of the prepared statement that has to be executed
61
     *
62
     * @return string The last inserted ID
63
     */
64
    public function create($row, $name = null)
65
    {
66
        return $this->getCreateProcessor()->execute($row, $name);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getCreateP...)->execute($row, $name) returns the type void which is incompatible with the documented return type string.
Loading history...
Bug introduced by
Are you sure the usage of $this->getCreateProcessor()->execute($row, $name) targeting TechDivision\Import\Acti...sorInterface::execute() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
67
    }
68
69
    /**
70
     * Update's the entity with the passed attributes.
71
     *
72
     * @param array       $row  The attributes of the entity to update
73
     * @param string|null $name The name of the prepared statement that has to be executed
74
     *
75
     * @return string The ID of the updated product
76
     */
77
    public function update($row, $name = null)
78
    {
79
        return $this->getUpdateProcessor()->execute($row, $name);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getUpdateP...)->execute($row, $name) returns the type void which is incompatible with the documented return type string.
Loading history...
Bug introduced by
Are you sure the usage of $this->getUpdateProcessor()->execute($row, $name) targeting TechDivision\Import\Acti...sorInterface::execute() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
80
    }
81
}
82