Passed
Pull Request — master (#13)
by Ihor
12:16 queued 07:59
created

CrefoPayUniqueIdGenerator::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 2
dl 0
loc 6
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\Dependency\Service\CrefoPayToUtilTextServiceInterface;
12
13
class CrefoPayUniqueIdGenerator implements CrefoPayUniqueIdGeneratorInterface
14
{
15
    /**
16
     * @var \SprykerEco\Service\CrefoPay\CrefoPayConfig $crefoPayConfig
0 ignored issues
show
Bug introduced by
The type SprykerEco\Service\CrefoPay\CrefoPayConfig 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...
17
     */
18
    protected $crefoPayConfig;
19
20
    /**
21
     * @var \SprykerEco\Service\CrefoPay\Dependency\Service\CrefoPayToUtilTextServiceInterface $utilTextService
22
     */
23
    protected $utilTextService;
24
25
    /**
26
     * @param \SprykerEco\Service\CrefoPay\CrefoPayConfig $crefoPayConfig
27
     * @param \SprykerEco\Service\CrefoPay\Dependency\Service\CrefoPayToUtilTextServiceInterface $utilTextService
28
     */
29
    public function __construct(
30
        CrefoPayConfig $crefoPayConfig,
0 ignored issues
show
Bug introduced by
The type SprykerEco\Service\Crefo...enerator\CrefoPayConfig 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...
31
        CrefoPayToUtilTextServiceInterface $utilTextService
32
    ) {
33
        $this->crefoPayConfig = $crefoPayConfig;
34
        $this->utilTextService = $utilTextService;
35
    }
36
37
    /**
38
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
39
     *
40
     * @return string
41
     */
42
    public function generateCrefoPayOrderId(QuoteTransfer $quoteTransfer): string
43
    {
44
        $crefoPayOrderIdLength = $this->crefoPayConfig->getCrefoPayOrderIdLength();
45
        $randomStringLength = $crefoPayOrderIdLength - strlen($quoteTransfer->getCustomerReference()) - 1;
46
47
        return sprintf(
48
            '%s-%s',
49
            $this->utilTextService->generateRandomString($randomStringLength),
50
            $quoteTransfer->getCustomerReference(),
51
        );
52
    }
53
}
54