Meta   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
c 1
b 0
f 0
dl 0
loc 72
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 13 3
A render() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Xetaravel\View\Components;
6
7
use Illuminate\Support\Str;
8
use Illuminate\Support\Facades\URL;
9
use Illuminate\View\Component;
10
use Closure;
11
12
class Meta extends Component
13
{
14
    /**
15
     * The meta title.
16
     *
17
     * @var string
18
     */
19
    public $title;
20
21
    /**
22
     * The meta author.
23
     *
24
     * @var string
25
     */
26
    public $author;
27
28
    /**
29
     * The meta description.
30
     *
31
     * @var string
32
     */
33
    public $description;
34
35
    /**
36
     * The meta url.
37
     *
38
     * @var string
39
     */
40
    public $url;
41
42
    /**
43
     * The meta image.
44
     *
45
     * @var string
46
     */
47
    public $image;
48
49
    /**
50
     * The meta copyright.
51
     *
52
     * @var string
53
     */
54
    public $copyright;
55
56
    /**
57
     * Create a new meta component instance.
58
     *
59
     * @return void
60
     */
61
    public function __construct(
62
        string $title = null,
63
        string $author = null,
64
        string $url = null,
65
        string $description = null
66
    ) {
67
        $this->title = $title ? Str::of($title)->limit(60, '...') . ' - Xetaravel' : config('xetaravel.site.title');
68
        $this->author = $author ?? config('xetaravel.site.copyright');
69
        $this->url = $url ?? URL::full();
70
        $this->description =
71
            $description ? Str::of(strip_tags($description))->limit(150, '...') : config('xetaravel.site.description');
72
        $this->copyright = config('xetaravel.site.copyright');
73
        $this->image = URL::asset('images/logo300x300.png');
74
    }
75
76
    /**
77
     * Get the view / contents that represent the component.
78
     *
79
     * @return \Illuminate\Contracts\View\View|Closure|string
80
     */
81
    public function render()
82
    {
83
        return view('components.meta');
84
    }
85
}
86