Skip to content

Commit

Permalink
Add options checking in cacheDirectory()
Browse files Browse the repository at this point in the history
  • Loading branch information
kylekatarnls committed Nov 14, 2020
1 parent 8bfe1d0 commit 5db12cb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .multi-tester.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ pug/bemto:
autoload:
- cp -r vendor/phug/phug vendor/phug/compiler
- cp -r vendor/phug/phug vendor/phug/formatter
- composer self-update 1.10.17
- composer dump-autoload --optimize --no-interaction --quiet
- composer self-update --2

pug-php/pug-assets: default

Expand All @@ -15,7 +17,9 @@ pug/slim: default
pug/twig:
autoload:
- cp -r vendor/phug/phug vendor/phug/compiler
- composer self-update 1.10.17
- composer dump-autoload --optimize --no-interaction --quiet
- composer self-update --2

ci-pug/ci-pug: default

Expand Down
19 changes: 14 additions & 5 deletions src/Phug/Phug/Phug/Phug.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Phug;

use InvalidArgumentException;
use Phug\Partial\ExtensionsTrait;
use Phug\Partial\FacadeOptionsTrait;

Expand Down Expand Up @@ -476,16 +477,24 @@ public static function getKeywords()
*/
public static function cacheDirectory($source, $destination = null, $options = null)
{
if ($destination && !is_array($destination)) {
$options = $options ?: [];
$destination = $destination ?: [];

if (!is_array($destination)) {
$destination = [
'cache_dir' => $destination,
];
}

return static::getRenderer(array_merge(
$options ?: [],
$destination ?: []
))->cacheDirectory($source);
if (!is_array($options)) {
throw new InvalidArgumentException(
"Expected \$options to be an array, got: ".
(@var_export($options, true) ?: (is_object($options) ? get_class($options) : gettype($options)))
);
}

return static::getRenderer(array_merge($options, $destination))
->cacheDirectory($source);
}

/**
Expand Down

0 comments on commit 5db12cb

Please sign in to comment.