LegalNoticeComposer::compose()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 9.7
c 0
b 0
f 0
cc 3
nc 3
nop 1
1
<?php
2
3
namespace App\Http\ViewComposers;
4
5
use Illuminate\View\View;
6
use Illuminate\Mail\Markdown;
7
8
class LegalNoticeComposer
9
{
10
    /**
11
     * Bind data to the view.
12
     *
13
     * @param  View  $view
14
     * @return void
15
     */
16
    public function compose(View $view)
17
    {
18
        $enable = false;
19
        $title = '';
20
        $contents = '';
21
        if (config('kleis.legal_notice')) {
22
            $mdfile = public_path('markdown/legal/'.config('kleis.legal_notice').'-'.config('app.locale').'.md');
23
            if (file_exists($mdfile)){
24
                list($title, $text) = explode(PHP_EOL, file_get_contents($mdfile), 2);
25
                $enable = true;
26
                $contents = Markdown::parse($text)->toHtml();
27
            }
28
        }
29
        $view->with('enable', $enable)
30
             ->with('title', $title)
31
             ->with('contents', $contents);
32
    }
33
}
34