Metadata   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 50
rs 10
c 0
b 0
f 0
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __toString() 0 3 1
A getRootDomElement() 0 7 2
A getAppendBeforeNode() 0 9 2
1
<?php
2
3
/**
4
 * Copyright 2015 SURFnet bv
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 *     http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
18
19
namespace Surfnet\StepupGateway\SamlStepupProviderBundle\Provider;
20
21
use DOMDocument;
22
use DOMElement;
23
use DOMNode;
24
use LogicException;
25
use Surfnet\SamlBundle\Signing\Signable;
26
27
class Metadata implements Signable
28
{
29
    /**
30
     * @var string
31
     */
32
    public $entityId;
33
34
    /**
35
     * @var string
36
     */
37
    public $assertionConsumerUrl;
38
39
    /**
40
     * @var string
41
     */
42
    public $ssoUrl;
43
44
    /**
45
     * @var string
46
     */
47
    public $idpCertificateFile;
48
49
    /**
50
     * @var DOMDocument
51
     */
52
    public $document;
53
54
    public function getRootDomElement(): DOMElement
55
    {
56
        if (!$this->document) {
57
            throw new LogicException('Cannot get the rootElement of Metadata before the document has been generated');
58
        }
59
60
        return $this->document->documentElement;
61
    }
62
63
    public function getAppendBeforeNode(): ?DOMNode
64
    {
65
        if (!$this->document) {
66
            throw new LogicException(
67
                'Cannot get the appendBeforeNode of Metadata before the document has been generated'
68
            );
69
        }
70
71
        return $this->document->documentElement->childNodes->item(0);
72
    }
73
74
    public function __toString()
75
    {
76
        return $this->document->saveXML();
77
    }
78
}
79