CleanHtml::set()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 4
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Mews\Purifier\Casts;
4
5
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
6
7
class CleanHtml implements CastsAttributes
8
{
9
    use WithConfig;
10
11
    /**
12
     * Clean the HTML when casting the given value.
13
     *
14
     * @param  \Illuminate\Database\Eloquent\Model  $model
15
     * @param  string  $key
16
     * @param  mixed  $value
17
     * @param  array  $attributes
18
     * @return array
19
     */
20
    public function get($model, $key, $value, $attributes)
21
    {
22
        return clean($value, $this->config);
0 ignored issues
show
Bug Best Practice introduced by
The expression return clean($value, $this->config) also could return the type string which is incompatible with the documented return type array.
Loading history...
23
    }
24
25
    /**
26
     * Prepare the given value for storage by cleaning the HTML.
27
     *
28
     * @param  \Illuminate\Database\Eloquent\Model  $model
29
     * @param  string  $key
30
     * @param  array  $value
31
     * @param  array  $attributes
32
     * @return string
33
     */
34
    public function set($model, $key, $value, $attributes)
35
    {
36
        return clean($value, $this->config);
0 ignored issues
show
Bug Best Practice introduced by
The expression return clean($value, $this->config) returns the type array which is incompatible with the documented return type string.
Loading history...
37
    }
38
}
39