Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
19 / 19
100.00% covered (success)
100.00%
7 / 7
CRAP
100.00% covered (success)
100.00%
1 / 1
Language
100.00% covered (success)
100.00%
19 / 19
100.00% covered (success)
100.00%
7 / 7
8
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
1
 getUri
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getCode
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
 getOrientation
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getVerticalWritingMode
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 jsonSerialize
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
1 / 1
2
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) 2022 (original work) Open Assessment Technologies SA;
19 *
20 * @author Gabriel Felipe Soares <gabriel.felipe.soares@taotesting.com>
21 */
22
23declare(strict_types=1);
24
25namespace oat\tao\model\Language;
26
27use JsonSerializable;
28
29class Language implements JsonSerializable
30{
31    /** @var string */
32    private $uri;
33
34    /** @var string */
35    private $code;
36
37    /** @var string */
38    private $label;
39
40    /** @var string */
41    private $orientation;
42
43    /** @var ?string */
44    private $verticalWritingMode;
45
46    public function __construct(
47        string $uri,
48        string $code,
49        string $label,
50        string $orientation,
51        ?string $verticalWritingMode = null
52    ) {
53        $this->uri = $uri;
54        $this->code = $code;
55        $this->orientation = $orientation;
56        $this->label = $label;
57        $this->verticalWritingMode = $verticalWritingMode;
58    }
59
60    public function getUri(): string
61    {
62        return $this->uri;
63    }
64
65    public function getCode(): string
66    {
67        return $this->code;
68    }
69
70    public function getLabel(): string
71    {
72        return $this->label;
73    }
74
75    public function getOrientation(): string
76    {
77        return $this->orientation;
78    }
79
80    public function getVerticalWritingMode(): ?string
81    {
82        return $this->verticalWritingMode;
83    }
84
85    public function jsonSerialize(): array
86    {
87        $properties = [
88            'uri' => $this->uri,
89            'code' => $this->code,
90            'label' => $this->label,
91            'orientation' => $this->orientation
92        ];
93        if ($this->verticalWritingMode) {
94            $properties['verticalWritingMode'] = $this->verticalWritingMode;
95        }
96        return $properties;
97    }
98}