ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
Icon.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 2017 Nils Haagen <nils.haagen@concepts-and-training.de> Extended GPL, see docs/LICENSE */
3 
5 
6 use ILIAS\UI\Component as C;
8 
9 class Icon implements C\Icon\Icon
10 {
11  use ComponentHelper;
12 
16  protected $name;
17 
21  protected $aria_label;
22 
26  protected $size;
27 
31  protected $abbreviation;
32 
36  protected static $possible_sizes = array(
37  self::SMALL,
38  self::MEDIUM,
39  self::LARGE
40  );
41 
42 
46  public function getName()
47  {
48  return $this->name;
49  }
50 
54  public function getAriaLabel()
55  {
56  return $this->aria_label;
57  }
58 
63  {
64  $this->checkStringArg("string", $abbreviation);
65  $clone = clone $this;
66  $clone->abbreviation = $abbreviation;
67  return $clone;
68  }
69 
73  public function getAbbreviation()
74  {
75  return $this->abbreviation;
76  }
77 
81  public function withSize($size)
82  {
83  $this->checkArgIsElement(
84  "size",
85  $size,
86  self::$possible_sizes,
87  implode(self::$possible_sizes, '/')
88  );
89  $clone = clone $this;
90  $clone->size = $size;
91  return $clone;
92  }
93 
97  public function getSize()
98  {
99  return $this->size;
100  }
101 }
checkArgIsElement($which, $value, $array, $name)
Throw an InvalidArgumentException if $value is not an element of array.
trait ComponentHelper
Provides common functionality for component implementations.
checkStringArg($which, $value)
Throw an InvalidArgumentException if $value is no string.
Create styles array
The data for the language used.