Completed
Push — master ( 0598e6...0379c1 )
by
unknown
13s queued 11s
created

TemplateSkeletons   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

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

2 Methods

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