Completed
Push — master ( 844dee...acb0bf )
by Joschi
02:38
created

Thing   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 62.5%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 1
dl 0
loc 73
c 0
b 0
f 0
ccs 10
cts 16
cp 0.625
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 14 2
A getType() 0 4 1
A getVocabulary() 0 4 1
A getId() 0 4 1
1
<?php
2
3
/**
4
 * rdfa-lite
5
 *
6
 * @category Jkphl
7
 * @package Jkphl\Rdfalite
8
 * @subpackage Jkphl\Rdfalite\Domain
9
 * @author Joschi Kuphal <[email protected]> / @jkphl
10
 * @copyright Copyright © 2017 Joschi Kuphal <[email protected]> / @jkphl
11
 * @license http://opensource.org/licenses/MIT The MIT License (MIT)
12
 */
13
14
/***********************************************************************************
15
 *  The MIT License (MIT)
16
 *
17
 *  Copyright © 2017 Joschi Kuphal <[email protected]> / @jkphl
18
 *
19
 *  Permission is hereby granted, free of charge, to any person obtaining a copy of
20
 *  this software and associated documentation files (the "Software"), to deal in
21
 *  the Software without restriction, including without limitation the rights to
22
 *  use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
23
 *  the Software, and to permit persons to whom the Software is furnished to do so,
24
 *  subject to the following conditions:
25
 *
26
 *  The above copyright notice and this permission notice shall be included in all
27
 *  copies or substantial portions of the Software.
28
 *
29
 *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30
 *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
31
 *  FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
32
 *  COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
33
 *  IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
34
 *  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35
 ***********************************************************************************/
36
37
namespace Jkphl\Rdfalite\Domain;
38
39
/**
40
 * Thing
41
 *
42
 * @package Jkphl\Rdfalite
43
 * @subpackage Jkphl\Rdfalite\Domain
44
 */
45
class Thing
46
{
47
    /**
48
     * Resource type
49
     *
50
     * @var string
51
     */
52
    protected $type;
53
    /**
54
     * Resource vocabulary
55
     *
56
     * @var Vocabulary
57
     */
58
    protected $vocabulary;
59
    /**
60
     * Resource ID
61
     *
62
     * @var string|null
63
     */
64
    protected $id = null;
65
66
    /**
67
     * Thing constructor
68
     *
69
     * @param string $type Resource type
70
     * @param Vocabulary $vocabulary Vocabulary in use
71
     * @param null|string $id Resource id
72
     */
73 2
    public function __construct($type, Vocabulary $vocabulary, $id = null)
74
    {
75 2
        $type = trim($type);
76 2
        if (!strlen($type)) {
77 1
            throw new Exception(
78 1
                sprintf(Exception::INVALID_RESOURCE_TYPE_STR, $type, $vocabulary->getUrl()),
79
                Exception::INVALID_RESOURCE_TYPE
80 1
            );
81
        }
82
83 1
        $this->type = $type;
84 1
        $this->vocabulary = $vocabulary;
85 1
        $this->id = $id;
86 1
    }
87
88
    /**
89
     * Return the resource type
90
     *
91
     * @return string Resource type
92
     */
93
    public function getType()
94
    {
95
        return $this->type;
96
    }
97
98
    /**
99
     * Return the vocabulary in use
100
     *
101
     * @return Vocabulary Vocabulary
102
     */
103
    public function getVocabulary()
104
    {
105
        return $this->vocabulary;
106
    }
107
108
    /**
109
     * Return the resource ID
110
     *
111
     * @return null|string Resource ID
112
     */
113
    public function getId()
114
    {
115
        return $this->id;
116
    }
117
}
118