PropertyRecordTrait   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 6
eloc 9
dl 0
loc 52
rs 10
c 2
b 1
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getType() 0 3 1
A setTypeFromObject() 0 5 1
A setType() 0 4 1
A updateType() 0 7 2
A getNewType() 0 4 1
1
<?php
2
3
namespace ByTIC\Models\SmartProperties\RecordsTraits\HasTypes;
4
5
use ByTIC\Models\SmartProperties\Properties\Types\Generic as GenericType;
6
7
trait PropertyRecordTrait
8
{
9
    /**
10
     * @return \ByTIC\Models\SmartProperties\Properties\AbstractProperty\Generic|GenericType
11
     */
12
    public function getType()
13
    {
14
        return $this->getSmartProperty('Type');
0 ignored issues
show
Bug introduced by
It seems like getSmartProperty() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

14
        return $this->/** @scrutinizer ignore-call */ getSmartProperty('Type');
Loading history...
15
    }
16
17
    /**
18
     * @param $status
19
     * @return \ByTIC\Models\SmartProperties\Properties\AbstractProperty\Generic|GenericType
20
     */
21
    public function getNewType($status)
22
    {
23
        /** @noinspection PhpUnhandledExceptionInspection */
24
        return $this->getNewSmartPropertyFromValue('Type', $status);
0 ignored issues
show
Bug introduced by
It seems like getNewSmartPropertyFromValue() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

24
        return $this->/** @scrutinizer ignore-call */ getNewSmartPropertyFromValue('Type', $status);
Loading history...
25
    }
26
27
    /**
28
     * @param GenericType $type
29
     * @return bool
30
     * @throws \Nip\Logger\Exception
31
     */
32
    public function updateType($type = null)
33
    {
34
        if ($this->setType($type)) {
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->setType($type) targeting ByTIC\Models\SmartProper...yRecordTrait::setType() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
35
            $this->update();
0 ignored issues
show
Bug introduced by
The method update() does not exist on ByTIC\Models\SmartProper...pes\PropertyRecordTrait. Did you maybe mean updateType()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

35
            $this->/** @scrutinizer ignore-call */ 
36
                   update();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
36
        }
37
38
        return false;
39
    }
40
41
    /**
42
     * @param $value
43
     */
44
    public function setType($value)
45
    {
46
        /** @noinspection PhpUnhandledExceptionInspection */
47
        $this->setSmartProperty('Type', $value);
0 ignored issues
show
Bug introduced by
It seems like setSmartProperty() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

47
        $this->/** @scrutinizer ignore-call */ 
48
               setSmartProperty('Type', $value);
Loading history...
48
    }
49
50
    /**
51
     * @param $typeObject
52
     * @return RecordTrait
53
     */
54
    public function setTypeFromObject($typeObject)
55
    {
56
        /** @noinspection PhpUnhandledExceptionInspection */
57
        $this->setSmartProperty('Type', $typeObject);
58
        return $typeObject;
59
    }
60
}
61