ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 abstract 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 $is_disabled;
37 
41  protected static $possible_sizes = array(
42  self::SMALL,
43  self::MEDIUM,
44  self::LARGE,
45  self::RESPONSIVE
46  );
47 
48 
52  public function getName()
53  {
54  return $this->name;
55  }
56 
60  public function getAriaLabel()
61  {
62  return $this->aria_label;
63  }
64 
69  {
70  $this->checkStringArg("string", $abbreviation);
71  $clone = clone $this;
72  $clone->abbreviation = $abbreviation;
73  return $clone;
74  }
75 
79  public function getAbbreviation()
80  {
81  return $this->abbreviation;
82  }
83 
87  public function withSize($size)
88  {
89  $this->checkArgIsElement(
90  "size",
91  $size,
92  self::$possible_sizes,
93  implode(self::$possible_sizes, '/')
94  );
95  $clone = clone $this;
96  $clone->size = $size;
97  return $clone;
98  }
99 
103  public function getSize()
104  {
105  return $this->size;
106  }
107 
111  public function isDisabled()
112  {
113  return $this->is_disabled;
114  }
115 
119  public function withDisabled($is_disabled)
120  {
121  $this->checkBoolArg("is_disabled", $is_disabled);
122  $clone = clone $this;
123  $clone->is_disabled = $is_disabled;
124  return $clone;
125  }
126 }
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.
checkBoolArg($which, $value)
Throw an InvalidArgumentException if $value is not a bool.