Completed
Push — master ( 896b70...2ed772 )
by Younes
07:16
created

Raty::cancel()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Yoeunes\Rateable\Services;
4
5
class Raty
6
{
7
    protected $element;
8
9
    public function element($element)
10
    {
11
        $this->element = $element;
12
13
        return $this;
14
    }
15
16
    public function render(array $options = [])
17
    {
18
        return $this->raty($this->raty_options($options));
19
    }
20
21
    private function raty_options(array $options = [])
22
    {
23
        $options = array_merge(config('rateable.raty.options'), $options);
24
25
        return json_encode($options);
26
    }
27
28
    public function jsrender(array $options = [])
29
    {
30
        return '<script type="text/javascript">'.$this->render($options).'</script>';
31
    }
32
33
    public function raty($options = '', $params = null)
0 ignored issues
show
Coding Style Best Practice introduced by
Please use __construct() instead of a PHP4-style constructor that is named after the class.
Loading history...
34
    {
35
        $params = null !== $params ? ', '.$params : '';
36
37
        return '$("'.$this->element.'").raty('.$options.$params.');';
38
    }
39
40
    public function score($score = null)
41
    {
42
        return $this->raty('score', $score);
43
    }
44
45
    public function click(int $number)
46
    {
47
        return $this->raty('click', $number);
48
    }
49
50
    public function readOnly(bool $status)
51
    {
52
        return $this->raty('readOnly', $status);
53
    }
54
55
    public function cancel(bool $status)
56
    {
57
        return $this->raty('cancel', $status);
58
    }
59
60
    public function reload()
61
    {
62
        return $this->raty('reload');
63
    }
64
65
    public function set(array $params = [])
66
    {
67
        return $this->raty(json_encode($params));
68
    }
69
70
    public function destroy()
71
    {
72
        return $this->raty('destroy');
73
    }
74
75
    public function move(int $number)
76
    {
77
        return $this->raty($number);
78
    }
79
}
80