Passed
Pull Request — master (#5)
by Carlos C
01:40
created

CancelSigner   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 34
ccs 11
cts 11
cp 1
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A dateTime() 0 3 1
A sign() 0 4 1
A __construct() 0 4 1
A uuids() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpCfdi\Finkok\Helpers;
6
7
use DateTimeImmutable;
8
use PhpCfdi\Credentials\Credential;
9
use PhpCfdi\XmlCancelacion\Credentials as XmlCancelacionCredentials;
10
use PhpCfdi\XmlCancelacion\XmlCancelacionHelper;
11
12
class CancelSigner
13
{
14
    /** @var array */
15
    private $uuids;
16
17
    /** @var DateTimeImmutable */
18
    private $dateTime;
19
20
    /**
21
     * CancelSigner constructor
22
     *
23
     * @param array $uuid
24
     * @param DateTimeImmutable|null $dateTime If null or ommited then use current time and time zone
25
     */
26 1
    public function __construct(array $uuid, ?DateTimeImmutable $dateTime = null)
27
    {
28 1
        $this->uuids = $uuid;
29 1
        $this->dateTime = $dateTime ?? new DateTimeImmutable();
30 1
    }
31
32 1
    public function uuids(): array
33
    {
34 1
        return $this->uuids;
35
    }
36
37 1
    public function dateTime(): DateTimeImmutable
38
    {
39 1
        return $this->dateTime;
40
    }
41
42 1
    public function sign(Credential $credential): string
43
    {
44 1
        $helper = new XmlCancelacionHelper(XmlCancelacionCredentials::createWithPhpCfdiCredential($credential));
45 1
        return $helper->signCancellationUuids($this->uuids(), $this->dateTime());
46
    }
47
}
48