Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
14 / 14
100.00% covered (success)
100.00%
7 / 7
CRAP
100.00% covered (success)
100.00%
1 / 1
ResourceRelation
100.00% covered (success)
100.00%
14 / 14
100.00% covered (success)
100.00%
7 / 7
7
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 getType
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getId
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 withSourceId
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getSourceId
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getLabel
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 jsonSerialize
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3/**
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; under version 2
7 * of the License (non-upgradable).
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17 *
18 * Copyright (c) 2020 (original work) Open Assessment Technologies SA;
19 */
20
21declare(strict_types=1);
22
23namespace oat\tao\model\resources\relation;
24
25use JsonSerializable;
26
27class ResourceRelation implements JsonSerializable
28{
29    /** @var string */
30    private $id;
31
32    /** @var string */
33    private $sourceId;
34
35    /** @var string */
36    private $label;
37
38    /** @var string */
39    private $type;
40
41    public function __construct(string $type, string $id, string $label = null)
42    {
43        $this->type = $type;
44        $this->id = $id;
45        $this->label = $label;
46    }
47
48    public function getType(): string
49    {
50        return $this->type;
51    }
52
53    public function getId(): string
54    {
55        return $this->id;
56    }
57
58    public function withSourceId(string $sourceId): self
59    {
60        $this->sourceId = $sourceId;
61
62        return $this;
63    }
64
65    public function getSourceId(): string
66    {
67        return $this->sourceId;
68    }
69
70    public function getLabel(): ?string
71    {
72        return $this->label;
73    }
74
75    public function jsonSerialize(): array
76    {
77        return [
78            'type' => $this->type,
79            'id' => $this->id,
80            'label' => $this->label ?? '',
81        ];
82    }
83}