Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 23 |
|
0.00% |
0 / 8 |
CRAP | |
0.00% |
0 / 1 |
| Icon | |
0.00% |
0 / 23 |
|
0.00% |
0 / 8 |
240 | |
0.00% |
0 / 1 |
| fromSimpleXMLElement | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
20 | |||
| fromArray | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
20 | |||
| createLegacyItem | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
| __construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| getId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getSource | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getExtension | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| __toPhpCode | |
0.00% |
0 / 4 |
|
0.00% |
0 / 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) 2014 (original work) Open Assessment Technologies SA; |
| 19 | * |
| 20 | * |
| 21 | */ |
| 22 | |
| 23 | namespace oat\tao\model\menu; |
| 24 | |
| 25 | use oat\oatbox\PhpSerializable; |
| 26 | use tao_models_classes_accessControl_AclProxy; |
| 27 | |
| 28 | class Icon implements PhpSerializable |
| 29 | { |
| 30 | public const SERIAL_VERSION = 1392821334; |
| 31 | |
| 32 | protected $data; |
| 33 | |
| 34 | /** |
| 35 | * @param \SimpleXMLElement $node |
| 36 | * @param string $structureExtensionId |
| 37 | * @return static |
| 38 | */ |
| 39 | public static function fromSimpleXMLElement(\SimpleXMLElement $node, $structureExtensionId) |
| 40 | { |
| 41 | |
| 42 | return new static([ |
| 43 | 'id' => !empty($node['id']) ? (string)$node['id'] : null, |
| 44 | 'src' => !empty($node['src']) ? (string)$node['src'] : null, |
| 45 | 'ext' => !empty($node['ext']) ? (string)$node['ext'] : $structureExtensionId |
| 46 | ]); |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * @param array $iconData |
| 51 | * @param string $structureExtensionId |
| 52 | * @return static |
| 53 | */ |
| 54 | public static function fromArray(array $iconData, $structureExtensionId) |
| 55 | { |
| 56 | return new static([ |
| 57 | 'id' => !empty($iconData['id']) ? (string)$iconData['id'] : null, |
| 58 | 'src' => !empty($iconData['src']) ? (string)$iconData['src'] : null, |
| 59 | 'ext' => !empty($iconData['ext']) ? (string)$iconData['ext'] : $structureExtensionId |
| 60 | ]); |
| 61 | } |
| 62 | |
| 63 | |
| 64 | |
| 65 | public static function createLegacyItem($iconId, $src = null) |
| 66 | { |
| 67 | return new static([ |
| 68 | 'id' => (string)$iconId, |
| 69 | 'src' => isset($src) ? (string)$src : null |
| 70 | ]); |
| 71 | } |
| 72 | |
| 73 | public function __construct($data, $version = self::SERIAL_VERSION) |
| 74 | { |
| 75 | $this->data = $data; |
| 76 | } |
| 77 | |
| 78 | public function getId() |
| 79 | { |
| 80 | return $this->data['id']; |
| 81 | } |
| 82 | |
| 83 | public function getSource() |
| 84 | { |
| 85 | return $this->data['src']; |
| 86 | } |
| 87 | |
| 88 | public function getExtension() |
| 89 | { |
| 90 | return $this->data['ext']; |
| 91 | } |
| 92 | |
| 93 | public function __toPhpCode() |
| 94 | { |
| 95 | return "new " . __CLASS__ . "(" |
| 96 | . \common_Utils::toPHPVariableString($this->data) . ',' |
| 97 | . \common_Utils::toPHPVariableString(self::SERIAL_VERSION) |
| 98 | . ")"; |
| 99 | } |
| 100 | } |