PostTemplates   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 25
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A list() 0 18 3
1
<?php
2
3
namespace App\Services;
4
5
use Illuminate\Support\Facades\Storage;
6
7
class PostTemplates
8
{
9
    /**
10
     * Get all the post templates as a collection.
11
     *
12
     * @return array
13
     */
14
    public static function list($type = 'post')
15
    {
16
        $dir = 'post-layouts';
17
        if ($type != 'post') {
18
            $dir = $type.'-layouts';
19
        }
20
        $postTemplatefilesList = collect([]);
21
        $postTemplatefiles = Storage::disk($dir)->files('');
22
23
        foreach ($postTemplatefiles as $postTemplatefile) {
24
            $name = substr($postTemplatefile, 0, strpos($postTemplatefile, '.blade.php'));
25
            $postTemplatefilesList[] = [
26
                'name' => $name,
27
                'path' => 'blog.'.$dir.'.'.$name,
28
            ];
29
        }
30
31
        return $postTemplatefilesList;
32
    }
33
}
34