From 67ea88dd1de3d3ee147d43f5f91506a47c16b187 Mon Sep 17 00:00:00 2001 From: Hamed Panjeh Date: Sun, 17 Dec 2023 10:48:45 -0300 Subject: [PATCH] Refactor array_map and array_filter --- src/ServiceProvider.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index 89bd85f..71c3167 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -55,15 +55,16 @@ public function getPugEngine(): Pug $config = $this->getConfig(); if (!isset($config['extensions']) && $this->app['view']) { - $extensions = array_keys(array_filter($this->app['view']->getExtensions(), function ($engine) { - $engines = explode('.', $engine); + $extensions = $this->app['view']->getExtensions(); + $filteredExtensions = []; - return in_array('pug', $engines); - })); + foreach ($extensions as $key => $engine) { + if (strpos($engine, 'pug') !== false) { + $filteredExtensions[] = ".$key"; + } + } - $config['extensions'] = array_map(function ($extension) { - return ".$extension"; - }, $extensions); + $config['extensions'] = $filteredExtensions; } $pug = new Pug($config);