TemplateSkeletons::get()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 11
c 1
b 0
f 0
nc 2
nop 3
dl 0
loc 15
rs 9.9
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