Code Duplication    Length = 40-46 lines in 2 locations

src/Repositories/ProductRepository.php 1 location

@@ 35-74 (lines=40) @@
32
 * @link      https://github.com/techdivision/import
33
 * @link      http://www.techdivision.com
34
 */
35
class ProductRepository extends AbstractRepository
36
{
37
38
    /**
39
     * The prepared statement to load the existing products.
40
     *
41
     * @var \PDOStatement
42
     */
43
    protected $productStmt;
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->productStmt =
58
            $this->getConnection()->prepare($this->getUtilityClass()->find($utilityClassName::PRODUCT));
59
    }
60
61
    /**
62
     * Return's the product with the passed SKU.
63
     *
64
     * @param string $sku The SKU of the product to return
65
     *
66
     * @return array The product
67
     */
68
    public function findOneBySku($sku)
69
    {
70
        // load and return the product with the passed SKU
71
        $this->productStmt->execute(array(MemberNames::SKU => $sku));
72
        return $this->productStmt->fetch(\PDO::FETCH_ASSOC);
73
    }
74
}
75

src/Repositories/UrlRewriteRepository.php 1 location

@@ 34-79 (lines=46) @@
31
 * @link      https://github.com/techdivision/import-product
32
 * @link      http://www.techdivision.com
33
 */
34
class UrlRewriteRepository extends \TechDivision\Import\Repositories\UrlRewriteRepository
35
{
36
37
    /**
38
     * The prepared statement to load the existing URL rewrites by a SKU.
39
     *
40
     * @var \PDOStatement
41
     */
42
    protected $urlRewritesBySkuStmt;
43
44
    /**
45
     * Initializes the repository's prepared statements.
46
     *
47
     * @return void
48
     */
49
    public function init()
50
    {
51
52
        // invoke the parent instance
53
        parent::init();
54
55
        // load the utility class name
56
        $utilityClassName = $this->getUtilityClassName();
57
58
        // initialize the prepared statements
59
        $this->urlRewritesBySkuStmt = $this->getConnection()->prepare($this->getUtilityClass()->find($utilityClassName::URL_REWRITES_BY_SKU));
60
    }
61
62
    /**
63
     * Return's an array with the URL rewrites for the passed SKU.
64
     *
65
     * @param string $sku The SKU to load the URL rewrites for
66
     *
67
     * @return array The URL rewrites
68
     */
69
    public function findAllBySku($sku)
70
    {
71
72
        // initialize the params
73
        $params = array(MemberNames::SKU => $sku);
74
75
        // load and return the URL rewrites for the passed SKU
76
        $this->urlRewritesBySkuStmt->execute($params);
77
        return $this->urlRewritesBySkuStmt->fetchAll(\PDO::FETCH_ASSOC);
78
    }
79
}
80