Skip to content

Commit 8aba647

Browse files
committed
refactor: by Rector and php-cs-fixer
1 parent 03d8c2c commit 8aba647

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

src/CI4Twig/Twig.php

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Twig\Error\SyntaxError;
1717
use Twig\Extension\DebugExtension;
1818
use Twig\Loader\FilesystemLoader;
19+
use Twig\TwigFilter;
1920
use Twig\TwigFunction;
2021

2122
class Twig
@@ -43,7 +44,7 @@ class Twig
4344
/**
4445
* @var array Filters to add to Twig
4546
*/
46-
private $filters = [];
47+
private array $filters = [];
4748

4849
/**
4950
* @var array Functions with `is_safe` option
@@ -93,10 +94,9 @@ public function __construct($params = [])
9394
}
9495

9596
if (isset($params['filters'])) {
96-
$this->filters =
97-
array_unique(
98-
array_merge($this->filters, $params['filters'])
99-
);
97+
$this->filters = array_unique(
98+
array_merge($this->filters, $params['filters'])
99+
);
100100
unset($params['filters']);
101101
}
102102

@@ -201,16 +201,14 @@ public function render($view, $params = []): string
201201

202202
protected function addFilters()
203203
{
204-
if( !empty($this->filters) ){
205-
foreach ($this->filters as $filter) {
206-
if (function_exists($filter)) {
207-
$this->twig->addFilter(
208-
new \Twig\TwigFilter(
209-
$filter,
210-
$filter
211-
)
212-
);
213-
}
204+
foreach ($this->filters as $filter) {
205+
if (function_exists($filter)) {
206+
$this->twig->addFilter(
207+
new TwigFilter(
208+
$filter,
209+
$filter
210+
)
211+
);
214212
}
215213
}
216214
}

0 commit comments

Comments
 (0)