Passed
Push — bugfix/supesc-227-extend-the-c... ( bf40aa...1b5338 )
by Oleh
04:23
created

generateCrefoPayOrderIdBasedOnCustomerReference()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
/**
4
 * MIT License
5
 * For full license information, please view the LICENSE file that was distributed with this source code.
6
 */
7
8
namespace SprykerEco\Service\CrefoPay\Generator;
9
10
use Generated\Shared\Transfer\QuoteTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\QuoteTransfer 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 SprykerEco\Service\CrefoPay\CrefoPayConfig;
12
use SprykerEco\Service\CrefoPay\Dependency\Service\CrefoPayToUtilTextServiceInterface;
13
14
class CrefoPayUniqueIdGenerator implements CrefoPayUniqueIdGeneratorInterface
15
{
16
    /**
17
     * @var \SprykerEco\Service\CrefoPay\CrefoPayConfig $config
18
     */
19
    protected $config;
20
21
    /**
22
     * @var \SprykerEco\Service\CrefoPay\Dependency\Service\CrefoPayToUtilTextServiceInterface $crefoPayUniqueIdGeneratorBridge
23
     */
24
    protected $crefoPayToUtilTextServiceBridge;
25
26
    /**
27
     * @param \SprykerEco\Service\CrefoPay\CrefoPayConfig $config
28
     * @param \SprykerEco\Service\CrefoPay\Dependency\Service\CrefoPayToUtilTextServiceInterface $crefoPayToUtilTextServiceBridge
29
     */
30
    public function __construct(
31
        CrefoPayConfig $config,
32
        CrefoPayToUtilTextServiceInterface $crefoPayToUtilTextServiceBridge
33
    ) {
34
        $this->config = $config;
35
        $this->crefoPayToUtilTextServiceBridge = $crefoPayToUtilTextServiceBridge;
36
    }
37
38
    /**
39
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
40
     *
41
     * @return string
42
     */
43
    public function generateCrefoPayOrderId(QuoteTransfer $quoteTransfer): string
44
    {
45
        return $this->config->getUseIndependentOrderIdForTransaction() ?
46
            $this->generateCrefoPayOrderIdIndependent() :
47
            $this->generateCrefoPayOrderIdBasedOnCustomerReference($quoteTransfer);
0 ignored issues
show
Deprecated Code introduced by
The function SprykerEco\Service\Crefo...edOnCustomerReference() has been deprecated: Use {@link \SprykerEco\Service\CrefoPay\Generator\CrefoPayUniqueIdGenerator::generateCrefoPayOrderIdIndependent()} instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

47
            /** @scrutinizer ignore-deprecated */ $this->generateCrefoPayOrderIdBasedOnCustomerReference($quoteTransfer);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
48
    }
49
50
    /**
51
     * @deprecated Use {@link \SprykerEco\Service\CrefoPay\Generator\CrefoPayUniqueIdGenerator::generateCrefoPayOrderIdIndependent()} instead.
52
     *
53
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
54
     *
55
     * @return string
56
     */
57
    protected function generateCrefoPayOrderIdBasedOnCustomerReference(QuoteTransfer $quoteTransfer): string
58
    {
59
        return uniqid($quoteTransfer->getCustomerReference() . '-', true);
60
    }
61
62
    /**
63
     * @return string
64
     */
65
    protected function generateCrefoPayOrderIdIndependent(): string
66
    {
67
        return $this->crefoPayToUtilTextServiceBridge->generateRandomString(30);
68
    }
69
}
70