Utils::createKeyDescriptor()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 1
dl 0
loc 11
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SAML2;
6
7
use SimpleSAML\SAML2\Compat\AbstractContainer;
8
use SimpleSAML\SAML2\Compat\ContainerSingleton;
9
use SimpleSAML\SAML2\XML\md\KeyDescriptor;
10
use SimpleSAML\XMLSecurity\XML\ds\KeyInfo;
11
use SimpleSAML\XMLSecurity\XML\ds\X509Certificate;
0 ignored issues
show
Bug introduced by
The type SimpleSAML\XMLSecurity\XML\ds\X509Certificate 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...
12
use SimpleSAML\XMLSecurity\XML\ds\X509Data;
0 ignored issues
show
Bug introduced by
The type SimpleSAML\XMLSecurity\XML\ds\X509Data 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...
13
14
/**
15
 * Helper functions for the SAML2 library.
16
 *
17
 * @package simplesamlphp/saml2
18
 */
19
class Utils
20
{
21
    /**
22
     * Create a KeyDescriptor with the given certificate.
23
     *
24
     * @param string $x509Data The certificate, as a base64-encoded PEM data.
25
     * @return \SimpleSAML\SAML2\XML\md\KeyDescriptor The keydescriptor.
26
     */
27
    public static function createKeyDescriptor(string $x509Data): KeyDescriptor
28
    {
29
        $x509Data = new X509Data([
30
            new X509Certificate($x509Data),
31
        ]);
32
33
        $keyInfo = new KeyInfo([
34
            $x509Data,
35
        ]);
36
37
        return new KeyDescriptor($keyInfo);
38
    }
39
40
41
    /**
42
     * @return \SimpleSAML\SAML2\Compat\AbstractContainer
43
     */
44
    public static function getContainer(): AbstractContainer
45
    {
46
        return ContainerSingleton::getInstance();
47
    }
48
}
49