Code Duplication    Length = 39-39 lines in 2 locations

src/Repositories/AttributeRepository.php 1 location

@@ 35-73 (lines=39) @@
32
 * @link      https://github.com/techdivision/import-attribute
33
 * @link      http://www.techdivision.com
34
 */
35
class AttributeRepository extends AbstractRepository
36
{
37
38
    /**
39
     * The prepared statement to load an existing EAV attribute by its attribute code.
40
     *
41
     * @var \PDOStatement
42
     */
43
    protected $attributeByAttributeCodeStmt;
44
45
    /**
46
     * Initializes the repository's prepared statements.
47
     *
48
     * @return void
49
     */
50
    public function init()
51
    {
52
53
        // load the utility class name
54
        $utilityClassName = $this->getUtilityClassName();
55
56
        // initialize the prepared statements
57
        $this->attributeByAttributeCodeStmt = $this->getConnection()->prepare($utilityClassName::ATTRIBUTE_BY_ATTRIBUTE_CODE);
58
    }
59
60
    /**
61
     * Return's the EAV attribute with the passed code.
62
     *
63
     * @param string $attributeCode The code of the EAV attribute to return
64
     *
65
     * @return array The EAV attribute
66
     */
67
    public function findOneByAttributeCode($attributeCode)
68
    {
69
        // load and return the EAV attribute with the passed code
70
        $this->attributeByAttributeCodeStmt->execute(array(MemberNames::ATTRIBUTE_CODE => $attributeCode));
71
        return $this->attributeByAttributeCodeStmt->fetch(\PDO::FETCH_ASSOC);
72
    }
73
}
74

src/Repositories/CatalogAttributeRepository.php 1 location

@@ 35-73 (lines=39) @@
32
 * @link      https://github.com/techdivision/import-attribute
33
 * @link      http://www.techdivision.com
34
 */
35
class CatalogAttributeRepository extends AbstractRepository
36
{
37
38
    /**
39
     * The prepared statement to load an existing EAV catalog attribute by its ID.
40
     *
41
     * @var \PDOStatement
42
     */
43
    protected $catalogAttributeStmt;
44
45
    /**
46
     * Initializes the repository's prepared statements.
47
     *
48
     * @return void
49
     */
50
    public function init()
51
    {
52
53
        // load the utility class name
54
        $utilityClassName = $this->getUtilityClassName();
55
56
        // initialize the prepared statements
57
        $this->catalogAttributeStmt = $this->getConnection()->prepare($utilityClassName::CATALOG_ATTRIBUTE);
58
    }
59
60
    /**
61
     * Return's the EAV catalog attribute with the passed ID.
62
     *
63
     * @param string $attributeId The ID of the EAV catalog attribute to return
64
     *
65
     * @return array The EAV catalog attribute
66
     */
67
    public function load($attributeId)
68
    {
69
        // load and return the EAV catalog attribute with the ID
70
        $this->catalogAttributeStmt->execute(array(MemberNames::ATTRIBUTE_ID => $attributeId));
71
        return $this->catalogAttributeStmt->fetch(\PDO::FETCH_ASSOC);
72
    }
73
}
74