FactFinderSdkIsNewExpander   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
eloc 12
c 2
b 0
f 0
dl 0
loc 40
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A expand() 0 8 1
A isNew() 0 11 3
1
<?php
2
3
/**
4
 * MIT License
5
 * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
6
 */
7
8
namespace SprykerEco\Zed\FactFinderSdk\Business\Expander;
9
10
use Generated\Shared\Transfer\CurrencyTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\CurrencyTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use Generated\Shared\Transfer\LocaleTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\LocaleTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use Generated\Shared\Transfer\StoreTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\StoreTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
use SprykerEco\Shared\FactFinderSdk\FactFinderSdkConstants;
14
15
class FactFinderSdkIsNewExpander extends FactFinderSdkAbstractExpander
16
{
17
    public const NEW_FROM = 'NewFrom';
18
    public const NEW_TO = 'NewTo';
19
20
    /**
21
     * @param \Generated\Shared\Transfer\LocaleTransfer $localeTransfer
22
     * @param \Generated\Shared\Transfer\CurrencyTransfer $currencyTransfer
23
     * @param \Generated\Shared\Transfer\StoreTransfer $storeTransfer
24
     * @param array $productData
25
     *
26
     * @return array
27
     */
28
    public function expand(LocaleTransfer $localeTransfer, CurrencyTransfer $currencyTransfer, StoreTransfer $storeTransfer, $productData)
29
    {
30
        $newFrom = strtotime($productData[static::NEW_FROM]);
31
        $newTo = strtotime($productData[static::NEW_TO]);
32
33
        $productData[FactFinderSdkConstants::ITEM_IS_NEW] = (int)$this->isNew($newFrom, $newTo);
34
35
        return $productData;
36
    }
37
38
    /**
39
     * @param int $newFrom
40
     * @param int $newTo
41
     *
42
     * @return bool
43
     */
44
    protected function isNew($newFrom, $newTo)
45
    {
46
        if ($newFrom > time()) {
47
            return false;
48
        }
49
50
        if ($newTo < time()) {
51
            return false;
52
        }
53
54
        return true;
55
    }
56
}
57