Completed
Push — 19.x ( 8328ae...eef76a )
by Tim
05:57
created

CacheKeys::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 9.6333
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
/**
4
 * TechDivision\Import\Product\Utils\CacheKeys
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 2016 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
18
 * @link      http://www.techdivision.com
19
 */
20
21
namespace TechDivision\Import\Product\Utils;
22
23
/**
24
 * A utility class that contains the cache keys.
25
 *
26
 * @author    Tim Wagner <[email protected]>
27
 * @copyright 2016 TechDivision GmbH <[email protected]>
28
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
29
 * @link      https://github.com/techdivision/import
30
 * @link      http://www.techdivision.com
31
 */
32
class CacheKeys extends \TechDivision\Import\Utils\CacheKeys
33
{
34
35
    /**
36
     * The cache key for products.
37
     *
38
     * @var string
39
     */
40
    const PRODUCT = 'product';
41
42
    /**
43
     * The cache key for product varchar attributes.
44
     *
45
     * @var string
46
     */
47
    const PRODUCT_VARCHAR = 'product_varchar';
48
49
    /**
50
     * The cache key for product integer attributes.
51
     *
52
     * @var string
53
     */
54
    const PRODUCT_INT = 'product_int';
55
56
    /**
57
     * The cache key for product datetime attribute.
58
     *
59
     * @var string
60
     */
61
    const PRODUCT_DATETIME = 'product_datetime';
62
63
    /**
64
     * The cache key for product decimal attribute.
65
     *
66
     * @var string
67
     */
68
    const PRODUCT_DECIMAL = 'product_decimal';
69
70
    /**
71
     * The cache key for product text attribute.
72
     *
73
     * @var string
74
     */
75
    const PRODUCT_TEXT = 'product_text';
76
77
    /**
78
     * Initializes the instance with the passed cache key.
79
     *
80
     * @param string $cacheKey The cache key use
81
     */
82
    public function __construct($cacheKey, array $cacheKeys = array())
83
    {
84
85
        // merge the passed cache keys with the one from this class
86
        $mergedCacheKeys = array_merge(
87
            array(
88
                CacheKeys::PRODUCT,
89
                CacheKeys::PRODUCT_VARCHAR,
90
                CacheKeys::PRODUCT_INT,
91
                CacheKeys::PRODUCT_DATETIME,
92
                CacheKeys::PRODUCT_DECIMAL,
93
                CacheKeys::PRODUCT_TEXT
94
            ),
95
            $cacheKeys
96
        );
97
98
        // pass them to the parent instance
99
        parent::__construct($cacheKey, $mergedCacheKeys);
0 ignored issues
show
Bug introduced by
The method __construct() cannot be called from this context as it is declared private in class TechDivision\Import\Utils\CacheKeys.

This check looks for access to methods that are not accessible from the current context.

If you need to make a method accessible to another context you can raise its visibility level in the defining class.

Loading history...
Unused Code introduced by
The call to CacheKeys::__construct() has too many arguments starting with $cacheKey.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
Unused Code introduced by
The call to the method TechDivision\Import\Utils\CacheKeys::__construct() seems un-needed as the method has no side-effects.

PHP Analyzer performs a side-effects analysis of your code. A side-effect is basically anything that might be visible after the scope of the method is left.

Let’s take a look at an example:

class User
{
    private $email;

    public function getEmail()
    {
        return $this->email;
    }

    public function setEmail($email)
    {
        $this->email = $email;
    }
}

If we look at the getEmail() method, we can see that it has no side-effect. Whether you call this method or not, no future calls to other methods are affected by this. As such code as the following is useless:

$user = new User();
$user->getEmail(); // This line could safely be removed as it has no effect.

On the hand, if we look at the setEmail(), this method _has_ side-effects. In the following case, we could not remove the method call:

$user = new User();
$user->setEmail('email@domain'); // This line has a side-effect (it changes an
                                 // instance variable).
Loading history...
100
    }
101
}
102