Passed
Pull Request — master (#130)
by
unknown
10:48
created

TemplateSkeletons   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

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

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
     *
25
     * @param mixed $type
26
     * @param mixed $name
27
     * @param mixed $skeleton
28
     * @return array|void
29
     */
30
    public static function get($type, $name, $skeleton)
31
    {
32
        $skeletonView = MailEclipse::VIEW_NAMESPACE."::skeletons.{$type}.{$name}.{$skeleton}";
33
34
        if (View::exists($skeletonView)) {
35
            $skeletonViewPath = View::make($skeletonView)->getPath();
36
            $templateContent = Storage::get($skeletonViewPath);
37
38
            return [
39
                'type' => $type,
40
                'name' => $name,
41
                'skeleton' => $skeleton,
42
                'template' => Replacer::toEditor($templateContent),
43
                'view' => $skeletonView,
44
                'view_path' => $skeletonViewPath,
45
            ];
46
        }
47
    }
48
}
49