@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | namespace Nexendrie\SiteGenerator; |
| 5 | 5 | |
@@ -8,12 +8,12 @@ discard block |
||
| 8 | 8 | */ |
| 9 | 9 | function findVendorDirectory(): string { |
| 10 | 10 | $recursionLimit = 10; |
| 11 | - $findVendor = function ($dirName = "vendor/bin", $dir = __DIR__) use (&$findVendor, &$recursionLimit) { |
|
| 12 | - if(!$recursionLimit--) { |
|
| 11 | + $findVendor = function($dirName = "vendor/bin", $dir = __DIR__) use (&$findVendor, &$recursionLimit) { |
|
| 12 | + if (!$recursionLimit--) { |
|
| 13 | 13 | throw new \Exception("Cannot find vendor directory."); |
| 14 | 14 | } |
| 15 | 15 | $found = $dir . "/$dirName"; |
| 16 | - if(is_dir($found) || is_file($found)) { |
|
| 16 | + if (is_dir($found) || is_file($found)) { |
|
| 17 | 17 | return dirname($found); |
| 18 | 18 | } |
| 19 | 19 | return $findVendor($dirName, dirname($dir)); |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | namespace Nexendrie\SiteGenerator; |
| 5 | 5 | |
@@ -26,11 +26,11 @@ discard block |
||
| 26 | 26 | protected $output; |
| 27 | 27 | |
| 28 | 28 | function __construct(string $source = NULL, string $output = NULL) { |
| 29 | - if(is_null($source)) { |
|
| 29 | + if (is_null($source)) { |
|
| 30 | 30 | $source = findVendorDirectory() . "/../"; |
| 31 | 31 | } |
| 32 | 32 | $this->setSource($source); |
| 33 | - if(is_null($output)) { |
|
| 33 | + if (is_null($output)) { |
|
| 34 | 34 | $output = findVendorDirectory() . "/../public/"; |
| 35 | 35 | } |
| 36 | 36 | FileSystem::createDir($output); |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | * @param string $source |
| 49 | 49 | */ |
| 50 | 50 | function setSource(string $source) { |
| 51 | - if(is_string($source) AND is_dir($source)) { |
|
| 51 | + if (is_string($source) AND is_dir($source)) { |
|
| 52 | 52 | $this->source = realpath($source); |
| 53 | 53 | } |
| 54 | 54 | } |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | * @param string $output |
| 65 | 65 | */ |
| 66 | 66 | function setOutput(string $output) { |
| 67 | - if(is_string($output)) { |
|
| 67 | + if (is_string($output)) { |
|
| 68 | 68 | $this->output = realpath($output); |
| 69 | 69 | } |
| 70 | 70 | } |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | $meta = [ |
| 79 | 79 | "title" => "" |
| 80 | 80 | ]; |
| 81 | - if(file_exists($metaFilename)) { |
|
| 81 | + if (file_exists($metaFilename)) { |
|
| 82 | 82 | $meta = Neon::decode(file_get_contents($metaFilename)); |
| 83 | 83 | } |
| 84 | 84 | return $meta; |
@@ -94,16 +94,16 @@ discard block |
||
| 94 | 94 | $source = $parser->parse(file_get_contents($filename)); |
| 95 | 95 | $meta = $this->getMeta($filename); |
| 96 | 96 | $html = file_get_contents(__DIR__ . "/template.html"); |
| 97 | - if(substr($source, -1) === PHP_EOL) { |
|
| 97 | + if (substr($source, -1) === PHP_EOL) { |
|
| 98 | 98 | $source = substr($source, 0, -1); |
| 99 | 99 | } |
| 100 | - if(strlen($meta["title"]) === 0) { |
|
| 100 | + if (strlen($meta["title"]) === 0) { |
|
| 101 | 101 | unset($meta["title"]); |
| 102 | 102 | $html = str_replace(" |
| 103 | 103 | <title>%%title%%</title>", "", $html); |
| 104 | 104 | } |
| 105 | 105 | $meta["source"] = $source; |
| 106 | - foreach($meta as $key => $value) { |
|
| 106 | + foreach ($meta as $key => $value) { |
|
| 107 | 107 | $html = str_replace("%%$key%%", $value, $html); |
| 108 | 108 | } |
| 109 | 109 | return $html; |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | ->from($this->source) |
| 122 | 122 | ->exclude("vendor", ".git", "tests"); |
| 123 | 123 | /** @var \SplFileInfo $file */ |
| 124 | - foreach($files as $file) { |
|
| 124 | + foreach ($files as $file) { |
|
| 125 | 125 | $path = dirname($file->getRealPath()); |
| 126 | 126 | $path = str_replace($this->source, "", $path); |
| 127 | 127 | $html = $this->createHtml($file->getRealPath()); |
@@ -1,5 +1,5 @@ |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | namespace Nexendrie\SiteGenerator; |
| 5 | 5 | |