Code Coverage  | 
      ||||||||||
Lines  | 
       Functions and Methods  | 
       Classes and Traits  | 
      ||||||||
| Total |         | 
       20.00%  | 
       3 / 15  | 
               | 
       50.00%  | 
       1 / 2  | 
       CRAP |         | 
       0.00%  | 
       0 / 1  | 
      
| ListCreatedResponse |         | 
       20.00%  | 
       3 / 15  | 
               | 
       50.00%  | 
       1 / 2  | 
       7.61 |         | 
       0.00%  | 
       0 / 1  | 
      
| __construct |         | 
       100.00%  | 
       3 / 3  | 
               | 
       100.00%  | 
       1 / 1  | 
       1 | |||
| jsonSerialize |         | 
       0.00%  | 
       0 / 12  | 
               | 
       0.00%  | 
       0 / 1  | 
       6 | |||
| 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) 2021 (original work) Open Assessment Technologies SA; | 
| 19 | */ | 
| 20 | |
| 21 | declare(strict_types=1); | 
| 22 | |
| 23 | namespace oat\taoBackOffice\model\lists; | 
| 24 | |
| 25 | use core_kernel_classes_Class; | 
| 26 | use core_kernel_classes_Resource; | 
| 27 | use JsonSerializable; | 
| 28 | use tao_helpers_Uri; | 
| 29 | |
| 30 | class ListCreatedResponse implements JsonSerializable | 
| 31 | { | 
| 32 | /** @var core_kernel_classes_Class */ | 
| 33 | private $list; | 
| 34 | |
| 35 | /** @var core_kernel_classes_Resource[] */ | 
| 36 | private $elements; | 
| 37 | |
| 38 | /** @var int */ | 
| 39 | private $totalCount; | 
| 40 | |
| 41 | public function __construct(core_kernel_classes_Class $list, array $elements = [], int $totalCount = 0) | 
| 42 | { | 
| 43 | $this->list = $list; | 
| 44 | $this->elements = $elements; | 
| 45 | $this->totalCount = $totalCount; | 
| 46 | } | 
| 47 | |
| 48 | public function jsonSerialize(): array | 
| 49 | { | 
| 50 | $elementsView = []; | 
| 51 | |
| 52 | foreach ($this->elements as $element) { | 
| 53 | $elementsView[] = [ | 
| 54 | 'uri' => $element->getUri(), | 
| 55 | 'label' => $element->getLabel() | 
| 56 | ]; | 
| 57 | } | 
| 58 | |
| 59 | return [ | 
| 60 | 'uri' => $this->list->getUri(), | 
| 61 | 'label' => $this->list->getLabel(), | 
| 62 | 'elements' => $elementsView, | 
| 63 | 'totalCount' => $this->totalCount, | 
| 64 | ]; | 
| 65 | } | 
| 66 | } |