TemplateSkeletons   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A skeletons() 0 3 1
A get() 0 15 2
1
<?php
2
3
namespace Qoraiche\MailEclipse\Utils;
4
5
use Illuminate\Support\Collection;
6
use Illuminate\Support\Facades\File;
7
use Illuminate\Support\Facades\View;
8
use Qoraiche\MailEclipse\MailEclipse;
9
10
class TemplateSkeletons
11
{
12
    /**
13
     * Gets the template Skeletons from the configuration file.
14
     *
15
     * @return \Illuminate\Support\Collection
16
     */
17
    public static function skeletons()
18
    {
19
        return new Collection(config('maileclipse.skeletons'));
20
    }
21
22
    /**
23
     * @param  mixed  $type
24
     * @param  mixed  $name
25
     * @param  mixed  $skeleton
26
     * @return array|void
27
     */
28
    public static function get($type, $name, $skeleton)
29
    {
30
        $skeletonView = MailEclipse::VIEW_NAMESPACE."::skeletons.{$type}.{$name}.{$skeleton}";
31
32
        if (View::exists($skeletonView)) {
33
            $skeletonViewPath = View::make($skeletonView)->getPath();
34
            $templateContent = File::get($skeletonViewPath);
35
36
            return [
37
                'type' => $type,
38
                'name' => $name,
39
                'skeleton' => $skeleton,
40
                'template' => Replacer::toEditor($templateContent),
41
                'view' => $skeletonView,
42
                'view_path' => $skeletonViewPath,
43
            ];
44
        }
45
    }
46
}
47