BaseModel::setAttribute()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 16
Code Lines 12

Duplication

Lines 16
Ratio 100 %

Importance

Changes 0
Metric Value
cc 3
eloc 12
nc 4
nop 2
dl 16
loc 16
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace App;
4
5
use File;
6
use Illuminate\Database\Eloquent\Model;
7
8
/**
9
 * ======================================
10
 * Attchment Model
11
 * ======================================
12
 * This is a model representing the attachment table.
13
 *
14
 * @author Ladybird <[email protected]>
15
 */
16
class BaseModel extends Model
17
{
18 View Code Duplication
    public function setAttribute($property, $value)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
19
    {
20
        require_once base_path('vendor'.DIRECTORY_SEPARATOR.'htmlpurifier'.DIRECTORY_SEPARATOR.'library'.DIRECTORY_SEPARATOR.'HTMLPurifier.auto.php');
21
        $path = base_path('vendor'.DIRECTORY_SEPARATOR.'htmlpurifier'.DIRECTORY_SEPARATOR.'library'.DIRECTORY_SEPARATOR.'HTMLPurifier'.DIRECTORY_SEPARATOR.'DefinitionCache'.DIRECTORY_SEPARATOR.'Serializer');
22
        if (!File::exists($path)) {
23
            File::makeDirectory($path, $mode = 0777, true, true);
24
        }
25
        $config = \HTMLPurifier_Config::createDefault();
26
        $config->set('HTML.Trusted', true);
27
        $config->set('Filter.YouTube', true);
28
        $purifier = new \HTMLPurifier($config);
29
        if ($value != strip_tags($value)) {
30
            $value = $purifier->purify($value);
31
        }
32
        parent::setAttribute($property, $value);
33
    }
34
}
35