Completed
Push — master ( 12d899...a33b7a )
by Avtandil
04:40
created

Localizable::getLocalizableColumn()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
eloc 3
c 1
b 0
f 1
nc 2
nop 0
dl 0
loc 6
ccs 0
cts 5
cp 0
crap 6
rs 9.4285
1
<?php
2
/*
3
 * This file is part of the Laravel MultiLang package.
4
 *
5
 * (c) Avtandil Kikabidze aka LONGMAN <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Longman\LaravelMultiLang\Models;
12
13
14
trait Localizable
15
{
16
17
18
    public static function bootLocalizable()
19
    {
20
        static::addGlobalScope(new LocalizableScope);
21
    }
22
23
    public function getLocalizableColumn()
24
    {
25
        $localizableColumn = isset(static::$localizableColumn) ? static::$localizableColumn : 'lang';
26
27
        return $localizableColumn;
28
    }
29
30
31
    public function getQualifiedLocalizableColumn()
32
    {
33
        return $this->getTable().'.'.$this->getLocalizableColumn();
0 ignored issues
show
Bug introduced by
It seems like getTable() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
34
    }
35
36
37
}
38