Completed
Push — master ( 337d70...6470c4 )
by Mihail
04:13
created

ActiveModel   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 5
Bugs 1 Features 1
Metric Value
wmc 3
c 5
b 1
f 1
lcom 1
cbo 4
dl 0
loc 16
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getLocaled() 0 8 3
1
<?php
2
3
namespace Ffcms\Core\Arch;
4
5
use Ffcms\Core\Helper\Serialize;
6
use Ffcms\Core\Helper\Type\Obj;
7
use Ffcms\Core\Helper\Type\Str;
8
use \Illuminate\Database\Eloquent\Model as LaravelModel;
9
10
/**
11
 * Class ActiveModel. Basic implementation of laravel active records model with predefined settings
12
 * @package Ffcms\Core\Arch
13
 */
14
class ActiveModel extends LaravelModel
15
{
16
    /**
17
     * Special function for locale stored attributes under serialization.
18
     * @param string $attribute
19
     * @return array|null|string
20
     */
21
    public function getLocaled($attribute)
22
    {
23
        if (!Obj::isString($attribute) || Str::likeEmpty($this->$attribute)) {
24
            return null;
25
        }
26
27
        return Serialize::getDecodeLocale($this->$attribute);
28
    }
29
}