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

TemplateSkeletons::skeletons()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
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