TemplateSkeletons::skeletons()   A
last analyzed

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\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