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

ActiveModel::getLocaled()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 3
eloc 4
nc 2
nop 1
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
}