Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
12 / 12
100.00% covered (success)
100.00%
4 / 4
CRAP
100.00% covered (success)
100.00%
1 / 1
SharedStimulus
100.00% covered (success)
100.00%
12 / 12
100.00% covered (success)
100.00%
4 / 4
4
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 getBody
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
 jsonSerialize
100.00% covered (success)
100.00%
6 / 6
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\taoMediaManager\model\sharedStimulus;
24
25use JsonSerializable;
26
27class SharedStimulus implements JsonSerializable
28{
29    /** @var string */
30    private $id;
31
32    /** @var string */
33    private $languageId;
34
35    /** @var string */
36    private $name;
37
38    /** @var string|null */
39    private $body;
40
41    public function __construct(string $id, string $name, string $languageId, string $body = null)
42    {
43        $this->id = $id;
44        $this->name = $name;
45        $this->languageId = $languageId;
46        $this->body = $body;
47    }
48
49    public function getBody(): ?string
50    {
51        return $this->body;
52    }
53
54    public function getId(): string
55    {
56        return $this->id;
57    }
58
59    /**
60     * @inheritDoc
61     */
62    public function jsonSerialize(): array
63    {
64        return [
65            'id' => $this->id,
66            'languageId' => $this->languageId,
67            'name' => $this->name,
68            'body' => str_replace(PHP_EOL, '', (string)$this->body),
69        ];
70    }
71}