19 declare(strict_types=1);
47 public function __construct(
string $scss_variables_settings_path)
55 if (is_dir($this->scss_variables_settings_path)) {
56 $files = scandir($this->scss_variables_settings_path, SCANDIR_SORT_ASCENDING);
57 foreach ($files as $file) {
58 $file_path = $this->scss_variables_settings_path .
'/' . $file;
59 if ($file !=
"." && $file !=
".." && !is_dir($file_path)) {
66 $this->scss_variables_settings_path
73 if (is_dir($this->scss_variables_settings_path)) {
74 $files = scandir($this->scss_variables_settings_path, SCANDIR_SORT_ASCENDING);
75 foreach ($files as $file) {
76 $file_path = $this->scss_variables_settings_path .
'/' . $file;
77 if ($file !=
"." && $file !=
".." && !is_dir($file_path)) {
78 $content = file_get_contents($file_path);
79 foreach ($replacements as $search => $replace) {
80 $content = str_replace($search, $replace, $content);
82 file_put_contents($file_path, $content);
91 public function write(
string $new_path =
""): void
93 if ($new_path ==
"") {
98 foreach ($this->files as $file) {
107 foreach ($this->files as $file) {
108 $output .= $file->getContent();
118 if (count($this->categories) == 0) {
119 foreach ($this->files as $file) {
120 $this->categories = array_merge($this->categories, $file->getCategories());
129 return $categories[$name];
137 if (count($this->variables) == 0) {
138 foreach ($this->files as $file) {
139 $this->variables = array_merge($this->variables, $file->getVariables());
148 return $categories[$name];
158 if ($variable->getCategoryName() == $category_name) {
159 $variables[] = $variable;
171 foreach ($variable->getReferences() as $reference) {
172 if ($variable_name == $reference) {
173 $references[] = $variable->getName();
183 $references_string =
'';
185 $references_string .=
"$reference; ";
187 return $references_string;
192 $references_string =
'';
194 $references_string .=
"$reference; ";
199 if ($references_string !=
'') {
200 if ($variable->getComment()) {
201 $info = $variable->getComment() .
'</br>' . $refs_wording .
' ' . $references_string;
203 $info = $refs_wording .
' ' . $references_string;
206 $info = $variable->getComment();
216 $out .= $variable->getForDelosOverride();
227 foreach ($this->files as $file) {
228 $item = array_merge($item, $file->getItems());
const FOLDER_OPENING_FAILED
getRefAndCommentAsString(string $variable_name, string $refs_wording)
__construct(string $scss_variables_settings_path)
getReferencesToVariableAsString(string $variable_name)
getCategoryByName(string $name)
getVariablesForDelosOverride()
string $scss_variables_settings_path
Complete path the the settings folder on the file system.
Capsules data of a Scss category in the variables to Scss file.
write(string $new_path="")
Write the complete files back to the file system (including comments and random content) ...
getReferencesToVariable(string $variable_name)
getVariableByName(string $name)
readAndreplaceContentOfFolder(array $replacements)
getVariablesPerCategory(string $category_name='')