ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilSystemStyleScssVariable.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 /***
22  * Capsules data of a Scss variable in the variables to Scss file. A Scss variable has the following structure:
23  * //** Comment to describe the variable
24  * @variable: value;
25  */
27 {
31  protected string $name = '';
32 
36  protected string $value = '';
37 
41  protected string $comment = '';
42 
46  protected string $category_name = '';
47 
51  protected array $references = [];
52 
53  public function __construct(
54  string $name,
55  string $value,
56  string $comment,
57  string $category_name,
58  array $references = []
59  ) {
60  $this->setName($name);
61  $this->setValue($value);
62  $this->setCategoryName($category_name);
63  $this->setComment($comment);
64  $this->setReferences($references);
65  }
66 
67  public function getName(): string
68  {
69  return $this->name;
70  }
71 
72  public function setName(string $name): void
73  {
74  $this->name = $name;
75  }
76 
77  public function getValue(): string
78  {
79  return $this->value;
80  }
81 
82  public function setValue(string $value): void
83  {
84  if ($this->getName() == 'il-icon-font-path') {
85  if ($value[0] != "\"") {
86  $value = "\"" . $value;
87  }
88  if (substr($value, -1, 1) != "\"") {
89  $value .= "\"";
90  }
91  }
92 
93  $value = str_replace(PHP_EOL, '', $value);
94  $this->value = str_replace("\n", '', $value);
95  }
96 
97  public function getComment(): string
98  {
99  return $this->comment;
100  }
101 
102  public function setComment(string $comment): void
103  {
104  $comment = str_replace(PHP_EOL, '', $comment);
105  $this->comment = str_replace("\n", '', $comment);
106  }
107 
108  public function getCategoryName(): string
109  {
110  return $this->category_name;
111  }
112 
113  public function setCategoryName(string $category_name): void
114  {
115  $this->category_name = $category_name;
116  }
117 
118  public function getReferences(): array
119  {
120  return $this->references;
121  }
122 
123  public function setReferences(array $references): void
124  {
125  $this->references = $references;
126  }
127 
131  public function getForDelosOverride(): string
132  {
133  return '$' . $this->getName() . ": globals.$" . $this->getName() .",\n";
134  }
135 
140  public function __toString(): string
141  {
142  $content = '';
143  if ($this->getComment()) {
144  $content .= '//** ' . $this->getComment() . "\n";
145  }
146  $content .= '$' . $this->getName() . ": " . $this->getValue() . ";\n";
147  return $content;
148  }
149 }
array $references
Set references to other variables that are used by this exact variable.
Abstracts content of a scss file.
getForDelosOverride()
This function will be needed for the main scss file to override the defaults for delos.
__construct(string $name, string $value, string $comment, string $category_name, array $references=[])
string $category_name
Scss Category which encloses this variable.
string $value
Value of the variable as set in the Scss file.
string $name
Name of the variable.
__toString()
This function will be needed to write the variable back to the Scss file and restore it&#39;s initial str...
string $comment
Comment to the variable as in the Scss file.