Code Duplication    Length = 18-18 lines in 2 locations

src/Services/ProductBunchProcessor.php 2 locations

@@ 1016-1033 (lines=18) @@
1013
     *
1014
     * @return string The ID of the persisted entity
1015
     */
1016
    public function persistProduct($product, $name = null)
1017
    {
1018
1019
        // persist the new entity and set the PK value in the entity
1020
        $product[$pkName = $this->getProductRepository()->getPrimaryKeyName()] = $this->getProductAction()->persist($product, $name);
1021
1022
        // load the cache adapter instance
1023
        $cacheAdapter = $this->getProductRepository()->getCacheAdapter();
1024
1025
        // we only want to replace existing values, NOT adding new ones as this is the responsibility of the repository
1026
        if ($cacheAdapter->isCached($uniqueKey = array(CacheKeys::PRODUCT => $product[$pkName]))) {
1027
            // add the entity value to the cache, register the cache key reference as well
1028
            $cacheAdapter->toCache($uniqueKey, $product, array(), array(), true);
1029
        }
1030
1031
        // return the ID of the persisted entity
1032
        return $product[$pkName];
1033
    }
1034
1035
    /**
1036
     * Persist's the passed product varchar attribute.
@@ 1043-1060 (lines=18) @@
1040
     *
1041
     * @return string The ID of the persisted attribute
1042
     */
1043
    public function persistProductVarcharAttribute($attribute, $name = null)
1044
    {
1045
1046
        // persist the new entity and set the PK value in the entity
1047
        $attribute[$pkName = $this->getProductVarcharRepository()->getPrimaryKeyName()] = $this->getProductVarcharAction()->persist($attribute, $name);
1048
1049
        // load the cache adapter instance
1050
        $cacheAdapter = $this->getProductVarcharRepository()->getCacheAdapter();
1051
1052
        // we only want to replace existing values, NOT adding new ones as this is the responsibility of the repository
1053
        if ($cacheAdapter->isCached($uniqueKey = array(CacheKeys::PRODUCT_VARCHAR => $attribute[$pkName]))) {
1054
            // add the attribute value to the cache, register the cache key reference as well
1055
            $cacheAdapter->toCache($uniqueKey, $attribute, array(), array(), true);
1056
        }
1057
1058
        // return the ID of the persisted attribute
1059
        return $attribute[$pkName];
1060
    }
1061
1062
    /**
1063
     * Persist's the passed product integer attribute.