@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | * Configuration constructor. |
| 35 | 35 | * |
| 36 | 36 | * @param string $configFile |
| 37 | - * @param ConsoleInterface|OutputInterface|null $output |
|
| 37 | + * @param ConsoleInterface $output |
|
| 38 | 38 | */ |
| 39 | 39 | public function __construct($configFile, $output = null) |
| 40 | 40 | { |
@@ -83,11 +83,17 @@ discard block |
||
| 83 | 83 | return $base; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | + /** |
|
| 87 | + * @return string[] |
|
| 88 | + */ |
|
| 86 | 89 | public function getDataFolders () |
| 87 | 90 | { |
| 88 | 91 | return $this->returnConfigOption('data'); |
| 89 | 92 | } |
| 90 | 93 | |
| 94 | + /** |
|
| 95 | + * @return string[] |
|
| 96 | + */ |
|
| 91 | 97 | public function getDataSets () |
| 92 | 98 | { |
| 93 | 99 | return $this->returnConfigOption('datasets'); |
@@ -133,6 +139,9 @@ discard block |
||
| 133 | 139 | return $this->configuration['twig']['autoescape']; |
| 134 | 140 | } |
| 135 | 141 | |
| 142 | + /** |
|
| 143 | + * @param string $name |
|
| 144 | + */ |
|
| 136 | 145 | private function returnConfigOption ($name, $default = null) |
| 137 | 146 | { |
| 138 | 147 | return (isset($this->configuration[$name]) ? $this->configuration[$name] : $default); |
@@ -36,7 +36,7 @@ |
||
| 36 | 36 | * @param string $configFile |
| 37 | 37 | * @param ConsoleInterface|OutputInterface|null $output |
| 38 | 38 | */ |
| 39 | - public function __construct($configFile, $output = null) |
|
| 39 | + public function __construct ($configFile, $output = null) |
|
| 40 | 40 | { |
| 41 | 41 | $this->configuration = array(); |
| 42 | 42 | $this->output = new ConsoleInterface($output); |
@@ -140,6 +140,9 @@ |
||
| 140 | 140 | return pathinfo($filename, PATHINFO_EXTENSION); |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | + /** |
|
| 144 | + * @param string $folderPath |
|
| 145 | + */ |
|
| 143 | 146 | public function isDir ($folderPath) |
| 144 | 147 | { |
| 145 | 148 | return is_dir($folderPath); |
@@ -66,9 +66,9 @@ discard block |
||
| 66 | 66 | { |
| 67 | 67 | $finder = new Finder(); |
| 68 | 68 | $finder->files() |
| 69 | - ->ignoreVCS(true) |
|
| 70 | - ->ignoreDotFiles(true) |
|
| 71 | - ->ignoreUnreadableDirs(); |
|
| 69 | + ->ignoreVCS(true) |
|
| 70 | + ->ignoreDotFiles(true) |
|
| 71 | + ->ignoreUnreadableDirs(); |
|
| 72 | 72 | |
| 73 | 73 | $finder->in( |
| 74 | 74 | empty(trim($searchIn)) ? getcwd() : $searchIn |
@@ -155,9 +155,9 @@ discard block |
||
| 155 | 155 | public function removeExtension ($filename) |
| 156 | 156 | { |
| 157 | 157 | return $this->appendPath( |
| 158 | - $this->getFolderPath($filename), |
|
| 159 | - $this->getBaseName($filename) |
|
| 160 | - ); |
|
| 158 | + $this->getFolderPath($filename), |
|
| 159 | + $this->getBaseName($filename) |
|
| 160 | + ); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | /** |
@@ -62,6 +62,10 @@ discard block |
||
| 62 | 62 | } |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | + /** |
|
| 66 | + * @param string $absolutePath |
|
| 67 | + * @param string $targetPath |
|
| 68 | + */ |
|
| 65 | 69 | public function copyFile ($absolutePath, $targetPath) |
| 66 | 70 | { |
| 67 | 71 | $targetPath = ltrim($targetPath, DIRECTORY_SEPARATOR); |
@@ -73,6 +77,10 @@ discard block |
||
| 73 | 77 | ); |
| 74 | 78 | } |
| 75 | 79 | |
| 80 | + /** |
|
| 81 | + * @param string $targetPath |
|
| 82 | + * @param string $fileContent |
|
| 83 | + */ |
|
| 76 | 84 | public function writeFile ($targetPath, $fileContent) |
| 77 | 85 | { |
| 78 | 86 | $outputFolder = $this->fs->getFolderPath($targetPath); |
@@ -98,6 +106,9 @@ discard block |
||
| 98 | 106 | )); |
| 99 | 107 | } |
| 100 | 108 | |
| 109 | + /** |
|
| 110 | + * @param string $pathFragments |
|
| 111 | + */ |
|
| 101 | 112 | private function buildPath ($pathFragments) |
| 102 | 113 | { |
| 103 | 114 | $paths = func_get_args(); |
@@ -15,7 +15,7 @@ |
||
| 15 | 15 | /** |
| 16 | 16 | * Returns a list of filters. |
| 17 | 17 | * |
| 18 | - * @return array |
|
| 18 | + * @return Twig_SimpleFilter[] |
|
| 19 | 19 | */ |
| 20 | 20 | public function getFilters() |
| 21 | 21 | { |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | * |
| 18 | 18 | * @return array |
| 19 | 19 | */ |
| 20 | - public function getFilters() |
|
| 20 | + public function getFilters () |
|
| 21 | 21 | { |
| 22 | 22 | return array( |
| 23 | 23 | new Twig_SimpleFilter('truncate', 'twig_truncate_filter', array('needs_environment' => true)), |
@@ -30,14 +30,14 @@ discard block |
||
| 30 | 30 | * |
| 31 | 31 | * @return string |
| 32 | 32 | */ |
| 33 | - public function getName() |
|
| 33 | + public function getName () |
|
| 34 | 34 | { |
| 35 | 35 | return 'Text'; |
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | if (function_exists('mb_get_info')) { |
| 40 | - function twig_truncate_filter(Twig_Environment $env, $value, $length = 30, $preserve = false, $separator = '...') |
|
| 40 | + function twig_truncate_filter (Twig_Environment $env, $value, $length = 30, $preserve = false, $separator = '...') |
|
| 41 | 41 | { |
| 42 | 42 | if (mb_strlen($value, $env->getCharset()) > $length) { |
| 43 | 43 | if ($preserve) { |
@@ -49,13 +49,13 @@ discard block |
||
| 49 | 49 | $length = $breakpoint; |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - return rtrim(mb_substr($value, 0, $length, $env->getCharset())).$separator; |
|
| 52 | + return rtrim(mb_substr($value, 0, $length, $env->getCharset())) . $separator; |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | return $value; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - function twig_wordwrap_filter(Twig_Environment $env, $value, $length = 80, $separator = "\n", $preserve = false) |
|
| 58 | + function twig_wordwrap_filter (Twig_Environment $env, $value, $length = 80, $separator = "\n", $preserve = false) |
|
| 59 | 59 | { |
| 60 | 60 | $sentences = array(); |
| 61 | 61 | |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | return implode($separator, $sentences); |
| 78 | 78 | } |
| 79 | 79 | } else { |
| 80 | - function twig_truncate_filter(Twig_Environment $env, $value, $length = 30, $preserve = false, $separator = '...') |
|
| 80 | + function twig_truncate_filter (Twig_Environment $env, $value, $length = 30, $preserve = false, $separator = '...') |
|
| 81 | 81 | { |
| 82 | 82 | if (strlen($value) > $length) { |
| 83 | 83 | if ($preserve) { |
@@ -86,13 +86,13 @@ discard block |
||
| 86 | 86 | } |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - return rtrim(substr($value, 0, $length)).$separator; |
|
| 89 | + return rtrim(substr($value, 0, $length)) . $separator; |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | return $value; |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - function twig_wordwrap_filter(Twig_Environment $env, $value, $length = 80, $separator = "\n", $preserve = false) |
|
| 95 | + function twig_wordwrap_filter (Twig_Environment $env, $value, $length = 80, $separator = "\n", $preserve = false) |
|
| 96 | 96 | { |
| 97 | 97 | return wordwrap($value, $length, $separator, !$preserve); |
| 98 | 98 | } |
@@ -36,13 +36,17 @@ discard block |
||
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | -if (function_exists('mb_get_info')) { |
|
| 39 | +if (function_exists('mb_get_info')) |
|
| 40 | +{ |
|
| 40 | 41 | function twig_truncate_filter(Twig_Environment $env, $value, $length = 30, $preserve = false, $separator = '...') |
| 41 | 42 | { |
| 42 | - if (mb_strlen($value, $env->getCharset()) > $length) { |
|
| 43 | - if ($preserve) { |
|
| 43 | + if (mb_strlen($value, $env->getCharset()) > $length) |
|
| 44 | + { |
|
| 45 | + if ($preserve) |
|
| 46 | + { |
|
| 44 | 47 | // If breakpoint is on the last word, return the value without separator. |
| 45 | - if (false === ($breakpoint = mb_strpos($value, ' ', $length, $env->getCharset()))) { |
|
| 48 | + if (false === ($breakpoint = mb_strpos($value, ' ', $length, $env->getCharset()))) |
|
| 49 | + { |
|
| 46 | 50 | return $value; |
| 47 | 51 | } |
| 48 | 52 | |
@@ -65,8 +69,10 @@ discard block |
||
| 65 | 69 | $pieces = mb_split($separator, $value); |
| 66 | 70 | mb_regex_encoding($previous); |
| 67 | 71 | |
| 68 | - foreach ($pieces as $piece) { |
|
| 69 | - while (!$preserve && mb_strlen($piece, $env->getCharset()) > $length) { |
|
| 72 | + foreach ($pieces as $piece) |
|
| 73 | + { |
|
| 74 | + while (!$preserve && mb_strlen($piece, $env->getCharset()) > $length) |
|
| 75 | + { |
|
| 70 | 76 | $sentences[] = mb_substr($piece, 0, $length, $env->getCharset()); |
| 71 | 77 | $piece = mb_substr($piece, $length, 2048, $env->getCharset()); |
| 72 | 78 | } |
@@ -76,12 +82,17 @@ discard block |
||
| 76 | 82 | |
| 77 | 83 | return implode($separator, $sentences); |
| 78 | 84 | } |
| 79 | -} else { |
|
| 85 | +} |
|
| 86 | +else |
|
| 87 | +{ |
|
| 80 | 88 | function twig_truncate_filter(Twig_Environment $env, $value, $length = 30, $preserve = false, $separator = '...') |
| 81 | 89 | { |
| 82 | - if (strlen($value) > $length) { |
|
| 83 | - if ($preserve) { |
|
| 84 | - if (false !== ($breakpoint = strpos($value, ' ', $length))) { |
|
| 90 | + if (strlen($value) > $length) |
|
| 91 | + { |
|
| 92 | + if ($preserve) |
|
| 93 | + { |
|
| 94 | + if (false !== ($breakpoint = strpos($value, ' ', $length))) |
|
| 95 | + { |
|
| 85 | 96 | $length = $breakpoint; |
| 86 | 97 | } |
| 87 | 98 | } |
@@ -76,10 +76,10 @@ |
||
| 76 | 76 | |
| 77 | 77 | $finder = new Finder(); |
| 78 | 78 | $finder->files() |
| 79 | - ->name('/\.(html|twig)/') |
|
| 80 | - ->ignoreDotFiles(true) |
|
| 81 | - ->ignoreUnreadableDirs() |
|
| 82 | - ->in($pageViewFolder); |
|
| 79 | + ->name('/\.(html|twig)/') |
|
| 80 | + ->ignoreDotFiles(true) |
|
| 81 | + ->ignoreUnreadableDirs() |
|
| 82 | + ->in($pageViewFolder); |
|
| 83 | 83 | |
| 84 | 84 | foreach ($finder as $viewFile) |
| 85 | 85 | { |
@@ -32,7 +32,7 @@ |
||
| 32 | 32 | /** |
| 33 | 33 | * PageManager constructor |
| 34 | 34 | */ |
| 35 | - public function __construct() |
|
| 35 | + public function __construct () |
|
| 36 | 36 | { |
| 37 | 37 | parent::__construct(); |
| 38 | 38 | |
@@ -58,7 +58,9 @@ discard block |
||
| 58 | 58 | */ |
| 59 | 59 | public function parsePageViews ($pageViewFolders) |
| 60 | 60 | { |
| 61 | - if (empty($pageViewFolders)) { return; } |
|
| 61 | + if (empty($pageViewFolders)) |
|
| 62 | + { |
|
| 63 | +return; } |
|
| 62 | 64 | |
| 63 | 65 | /** |
| 64 | 66 | * The name of the folder where PageViews are located |
@@ -109,7 +111,9 @@ discard block |
||
| 109 | 111 | */ |
| 110 | 112 | public function prepareDynamicPageViews ($collections) |
| 111 | 113 | { |
| 112 | - if (empty($collections)) { return; } |
|
| 114 | + if (empty($collections)) |
|
| 115 | + { |
|
| 116 | +return; } |
|
| 113 | 117 | |
| 114 | 118 | foreach ($this->dynamicPageViews as $pageView) |
| 115 | 119 | { |
@@ -112,9 +112,9 @@ |
||
| 112 | 112 | $dataItems = array(); |
| 113 | 113 | $finder = new Finder(); |
| 114 | 114 | $finder->files() |
| 115 | - ->ignoreDotFiles(true) |
|
| 116 | - ->ignoreUnreadableDirs() |
|
| 117 | - ->in($this->fs->absolutePath($folder)); |
|
| 115 | + ->ignoreDotFiles(true) |
|
| 116 | + ->ignoreUnreadableDirs() |
|
| 117 | + ->in($this->fs->absolutePath($folder)); |
|
| 118 | 118 | |
| 119 | 119 | foreach ($finder as $dataItem) |
| 120 | 120 | { |
@@ -64,7 +64,9 @@ discard block |
||
| 64 | 64 | */ |
| 65 | 65 | public function parseDataItems ($folders) |
| 66 | 66 | { |
| 67 | - if ($folders === null) { return; } |
|
| 67 | + if ($folders === null) |
|
| 68 | + { |
|
| 69 | +return; } |
|
| 68 | 70 | |
| 69 | 71 | foreach ($folders as $folder) |
| 70 | 72 | { |
@@ -84,7 +86,9 @@ discard block |
||
| 84 | 86 | */ |
| 85 | 87 | public function parseDataSets ($dataSets) |
| 86 | 88 | { |
| 87 | - if ($dataSets === null) { return; } |
|
| 89 | + if ($dataSets === null) |
|
| 90 | + { |
|
| 91 | +return; } |
|
| 88 | 92 | |
| 89 | 93 | /** |
| 90 | 94 | * The information which each DataSet has from the configuration file |
@@ -60,7 +60,7 @@ |
||
| 60 | 60 | * |
| 61 | 61 | * @param InputInterface $input |
| 62 | 62 | * |
| 63 | - * @return bool True if the website was configured properly |
|
| 63 | + * @return boolean|null True if the website was configured properly |
|
| 64 | 64 | */ |
| 65 | 65 | protected function configureBuild (InputInterface $input) |
| 66 | 66 | { |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | private $collections; |
| 14 | 14 | |
| 15 | - public function __construct() |
|
| 15 | + public function __construct () |
|
| 16 | 16 | { |
| 17 | 17 | parent::__construct(); |
| 18 | 18 | |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | { |
| 9 | 9 | protected $engine; |
| 10 | 10 | |
| 11 | - public function __construct($instanceName = null) |
|
| 11 | + public function __construct ($instanceName = null) |
|
| 12 | 12 | { |
| 13 | 13 | $this->engine = MarkdownEngine::instance($instanceName); |
| 14 | 14 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | /** |
| 17 | 17 | * {@inheritdoc} |
| 18 | 18 | */ |
| 19 | - public function transform($content) |
|
| 19 | + public function transform ($content) |
|
| 20 | 20 | { |
| 21 | 21 | return $this->engine->parse($content); |
| 22 | 22 | } |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | /** |
| 25 | 25 | * {@inheritdoc} |
| 26 | 26 | */ |
| 27 | - public function getName() |
|
| 27 | + public function getName () |
|
| 28 | 28 | { |
| 29 | 29 | return 'stakx/parsedown'; |
| 30 | 30 | } |