Formatter::toAsn()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 5
rs 10
1
<?php
2
declare(strict_types=1);
3
4
namespace Mdanter\Ecc\Serializer\Signature\Der;
5
6
use FG\ASN1\Universal\Integer;
7
use FG\ASN1\Universal\Sequence;
8
use Mdanter\Ecc\Crypto\Signature\SignatureInterface;
9
10
class Formatter
11
{
12
    /**
13
     * @param SignatureInterface $signature
14
     * @return Sequence
15
     */
16
    public function toAsn(SignatureInterface $signature): Sequence
17
    {
18
        return new Sequence(
19
            new Integer(gmp_strval($signature->getR(), 10)),
0 ignored issues
show
Bug introduced by
gmp_strval($signature->getR(), 10) of type string is incompatible with the type integer expected by parameter $value of FG\ASN1\Universal\Integer::__construct(). ( Ignorable by Annotation )

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

19
            new Integer(/** @scrutinizer ignore-type */ gmp_strval($signature->getR(), 10)),
Loading history...
20
            new Integer(gmp_strval($signature->getS(), 10))
21
        );
22
    }
23
24
    /**
25
     * @param SignatureInterface $signature
26
     * @return string
27
     */
28
    public function serialize(SignatureInterface $signature): string
29
    {
30
        return $this->toAsn($signature)->getBinary();
31
    }
32
}
33