X509Credential::getCertificate()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
/*
4
 * This file is part of the LightSAML-Core package.
5
 *
6
 * (c) Milos Tomic <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace LightSaml\Credential;
13
14
use RobRichards\XMLSecLibs\XMLSecurityKey;
15
16
class X509Credential extends AbstractCredential implements X509CredentialInterface
17
{
18
    /** @var X509Certificate */
19
    protected $certificate;
20
21
    /**
22
     * @param X509Certificate $certificate
23
     * @param XMLSecurityKey  $privateKey
24
     */
25 22
    public function __construct(X509Certificate $certificate, XMLSecurityKey $privateKey = null)
26
    {
27 22
        parent::__construct();
28 22
        $this->certificate = $certificate;
29
30 22
        $this->setPublicKey(KeyHelper::createPublicKey($certificate));
31
32 22
        $this->setKeyNames(array($this->getCertificate()->getName()));
0 ignored issues
show
Documentation introduced by
array($this->getCertificate()->getName()) is of type array<integer,string,{"0":"string"}>, but the function expects a array<integer,object<string>>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
33
34 22
        if ($privateKey) {
35 21
            $this->setPrivateKey($privateKey);
36
        }
37 22
    }
38
39
    /**
40
     * @return X509Certificate
41
     */
42 22
    public function getCertificate()
43
    {
44 22
        return $this->certificate;
45
    }
46
}
47