Code Duplication    Length = 17-17 lines in 2 locations

src/Generator.php 2 locations

@@ 132-148 (lines=17) @@
129
    }
130
  }
131
  
132
  protected function normalizeStyles(array &$meta, string &$html, string $filename): void {
133
    $basePath = dirname($filename);
134
    $meta["styles"] = array_filter($meta["styles"], function($value) use($basePath) {
135
      return file_exists("$basePath/$value");
136
    });
137
    if(!count($meta["styles"])) {
138
      unset($meta["styles"]);
139
      $html = str_replace("
140
  %%styles%%", "", $html);
141
      return;
142
    }
143
    array_walk($meta["styles"], function(&$value) use($basePath) {
144
      $this->addAsset("$basePath/$value");
145
      $value = "<link rel=\"stylesheet\" type=\"text/css\" href=\"$value\">";
146
    });
147
    $meta["styles"] = implode("\n  ", $meta["styles"]);
148
  }
149
  
150
  protected function normalizeScripts(array &$meta, string &$html, string $filename): void {
151
    $basePath = dirname($filename);
@@ 150-166 (lines=17) @@
147
    $meta["styles"] = implode("\n  ", $meta["styles"]);
148
  }
149
  
150
  protected function normalizeScripts(array &$meta, string &$html, string $filename): void {
151
    $basePath = dirname($filename);
152
    $meta["scripts"] = array_filter($meta["scripts"], function($value) use($basePath) {
153
      return file_exists("$basePath/$value");
154
    });
155
    if(!count($meta["scripts"])) {
156
      unset($meta["scripts"]);
157
      $html = str_replace("
158
  %%scripts%%", "", $html);
159
      return;
160
    }
161
    array_walk($meta["scripts"], function(&$value) use($basePath) {
162
      $this->addAsset("$basePath/$value");
163
      $value = "<script type=\"text/javascript\" src=\"$value\"></script>";
164
    });
165
    $meta["scripts"] = implode("\n  ", $meta["scripts"]);
166
  }
167
  
168
  protected function createMarkdownParser(): \cebe\markdown\Markdown {
169
    $parser = new class extends GithubMarkdown {