Completed
Push — master ( cf2d59...36802d )
by André
16:28
created

ObjectState::getName()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 8
Ratio 100 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 8
loc 8
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * File containing the ObjectState class.
5
 *
6
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
7
 * @license For full copyright and license information view LICENSE file distributed with this source code.
8
 */
9
namespace eZ\Publish\Core\Repository\Values\ObjectState;
10
11
use eZ\Publish\API\Repository\Values\ObjectState\ObjectState as APIObjectState;
12
use eZ\Publish\Core\Repository\Values\MultiLanguageDescriptionTrait;
13
use eZ\Publish\Core\Repository\Values\MultiLanguageNameTrait;
14
use eZ\Publish\Core\Repository\Values\MultiLanguageTrait;
15
16
/**
17
 * This class represents a object state value.
18
 *
19
 * @property-read mixed $id the id of the content type group
20
 * @property-read string $identifier the identifier of the content type group
21
 * @property-read int $priority the priority in the group ordering
22
 * @property-read string $mainLanguageCode the default language of the object state names and descriptions used for fallback.
23
 * @property-read string $defaultLanguageCode deprecated, use $mainLanguageCode
24
 * @property-read string[] $languageCodes the available languages
25
 *
26
 * @internal Meant for internal use by Repository, type hint against API object instead.
27
 */
28 View Code Duplication
class ObjectState extends APIObjectState
0 ignored issues
show
Duplication introduced by
This class 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...
29
{
30
    use MultiLanguageTrait;
31
    use MultiLanguageNameTrait;
32
    use MultiLanguageDescriptionTrait;
33
34
    /**
35
     * @var \eZ\Publish\API\Repository\Values\ObjectState\ObjectStateGroup
36
     */
37
    protected $objectStateGroup;
38
39
    /**
40
     * The object state group this object state belongs to.
41
     *
42
     * @return \eZ\Publish\API\Repository\Values\ObjectState\ObjectStateGroup
43
     */
44
    public function getObjectStateGroup()
45
    {
46
        return $this->objectStateGroup;
47
    }
48
49
    /**
50
     * Magic getter for BC reasons.
51
     *
52
     * @param string $property
53
     * @return mixed
54
     */
55
    public function __get($property)
56
    {
57
        if ($property === 'defaultLanguageCode') {
58
            @trigger_error(
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
59
                __CLASS__ . '::$defaultLanguageCode is deprecated. Use mainLanguageCode',
60
                E_USER_DEPRECATED
61
            );
62
63
            return $this->mainLanguageCode;
64
        }
65
66
        return parent::__get($property);
67
    }
68
69
    /**
70
     * Magic isset for BC reasons.
71
     *
72
     * @param string $property
73
     * @return bool
74
     */
75
    public function __isset($property)
76
    {
77
        if ($property === 'defaultLanguageCode') {
78
            @trigger_error(
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
79
                __CLASS__ . '::$defaultLanguageCode is deprecated. Use mainLanguageCode'
80
            );
81
82
            return true;
83
        }
84
85
        return parent::__isset($property);
86
    }
87
}
88