GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 78d09e...a6964a )
by Denis
02:46
created

Core::buildCoreXML()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
namespace Ellumilel\DocProps;
3
4
/**
5
 * @link https://en.wikipedia.org/wiki/Office_Open_XML_file_formats#Document_properties
6
 *
7
 * Class Core
8
 * @package Ellumilel\DocProps
9
 * @author Denis Tikhonov <[email protected]>
10
 */
11
class Core
12
{
13
    /** @var string */
14
    private $author = 'Unknown Author';
15
    /** @var int */
16
    private $revision = 0;
17
    /** @var string */
18
    private $urlCp = 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties';
19
    /** @var string */
20
    private $urlDc = 'http://purl.org/dc/elements/1.1/';
21
    /** @var string */
22
    private $urlDcType = 'http://purl.org/dc/dcmitype/';
23
    /** @var string */
24
    private $urlDcTerms = 'http://purl.org/dc/terms/';
25
    /** @var string */
26
    private $urlSchema = 'http://www.w3.org/2001/XMLSchema-instance';
27
    /** @var string */
28
    private $xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";
29
30
    /**
31
     * Core constructor.
32
     *
33
     * @param string $author
34
     * @param integer $revision
35
     */
36
    public function __construct($author = '', $revision = 0)
37
    {
38
        if (!empty($author)) {
39
            $this->author = $author;
40
        }
41
42
        $this->revision = $revision;
43
    }
44
45
    /**
46
     * @return string
47
     */
48
    public function buildCoreXML()
49
    {
50
        $coreXml = '';
51
        $coreXml .= $this->xml;
52
        $coreXml .= $this->getCoreProperties();
53
54
        return $coreXml;
55
    }
56
57
    /**
58
     * @return string
59
     */
60
    private function getCoreProperties()
61
    {
62
        $properties = '<cp:coreProperties xmlns:cp="'.$this->urlCp.'" xmlns:dc="'.
63
            $this->urlDc.'" xmlns:dcmitype="'.$this->urlDcType.'" xmlns:dcterms="'.
64
            $this->urlDcTerms.'" xmlns:xsi="'.$this->urlSchema.'">';
65
        $properties .= $this->created();
66
        $properties .= $this->creator();
67
        $properties .= $this->revision();
68
        $properties .= '</cp:coreProperties>';
69
70
        return $properties;
71
    }
72
73
    /**
74
     * CreatedDate ex: '2016-08-30T15:52:19.00Z';
75
     * @return string
76
     */
77
    private function created()
78
    {
79
        return '<dcterms:created xsi:type="dcterms:W3CDTF">'.date("Y-m-d\TH:i:s.00\Z").'</dcterms:created>';
80
    }
81
82
    /**
83
     * @return string
84
     */
85
    private function creator()
86
    {
87
        return '<dc:creator>'.str_replace("'", "&#39;", htmlspecialchars($this->author)).'</dc:creator>';
88
    }
89
90
    /**
91
     * @return string
92
     */
93
    private function revision()
94
    {
95
        return '<cp:revision>'.$this->revision.'</cp:revision>';
96
    }
97
}
98