Code Duplication    Length = 47-47 lines in 2 locations

src/Actions/AttributeAction.php 1 location

@@ 35-81 (lines=47) @@
32
 * @link      https://github.com/techdivision/import-attribute
33
 * @link      http://www.techdivision.com
34
 */
35
class AttributeAction extends AbstractAction
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);
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);
80
    }
81
}
82

src/Actions/AttributeOptionAction.php 1 location

@@ 35-81 (lines=47) @@
32
 * @link      https://github.com/techdivision/import-attribute
33
 * @link      http://www.techdivision.com
34
 */
35
class AttributeOptionAction extends AbstractAction
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);
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);
80
    }
81
}
82