Passed
Pull Request — master (#5)
by Carlos C
02:00
created

GetRelatedSigner::uuid()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpCfdi\Finkok\Helpers;
6
7
use PhpCfdi\Credentials\Credential;
8
use PhpCfdi\Finkok\Definitions\RfcRole;
9
use PhpCfdi\XmlCancelacion\Credentials;
10
use PhpCfdi\XmlCancelacion\XmlCancelacionHelper;
11
12
class GetRelatedSigner
13
{
14
    public const DEFAULT_PACRFC = 'CVD110412TF6';
15
16
    /** @var string */
17
    private $uuid;
18
19
    /** @var RfcRole */
20
    private $role;
21
22
    /** @var string */
23
    private $pacRfc;
24
25
    /**
26
     * GetRelatedSigner constructor.
27
     *
28
     * @param string $uuid
29
     * @param RfcRole|null $role If null or ommited then uses issuer role
30
     * @param string $pacRfc If empty or ommited then uses DEFAULT_PACRFC
31
     */
32 1
    public function __construct(string $uuid, RfcRole $role = null, string $pacRfc = self::DEFAULT_PACRFC)
33
    {
34 1
        $this->uuid = $uuid;
35 1
        $this->role = $role ?? RfcRole::issuer();
36 1
        $this->pacRfc = $pacRfc ?: static::DEFAULT_PACRFC;
37 1
    }
38
39 1
    public function uuid(): string
40
    {
41 1
        return $this->uuid;
42
    }
43
44 1
    public function role(): RfcRole
45
    {
46 1
        return $this->role;
47
    }
48
49 1
    public function pacRfc(): string
50
    {
51 1
        return $this->pacRfc;
52
    }
53
54 1
    public function sign(Credential $credential): string
55
    {
56 1
        $helper = new XmlCancelacionHelper(Credentials::createWithPhpCfdiCredential($credential));
57 1
        return $helper->signObtainRelated($this->uuid(), $this->role(), $this->pacRfc());
58
    }
59
}
60