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

ObjectStateGroup::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 ObjectStateGroup 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\ObjectStateGroup as APIObjectStateGroup;
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 an object state group 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 string $mainLanguageCode the default language of the object state group names and description used for fallback.
22
 * @property-read string $defaultLanguageCode deprecated, use $mainLanguageCode
23
 * @property-read string[] $languageCodes the available languages
24
 *
25
 * @internal Meant for internal use by Repository, type hint against API object instead.
26
 */
27 View Code Duplication
class ObjectStateGroup extends APIObjectStateGroup
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...
28
{
29
    use MultiLanguageTrait;
30
    use MultiLanguageNameTrait;
31
    use MultiLanguageDescriptionTrait;
32
33
    /**
34
     * Magic getter for BC reasons.
35
     *
36
     * @param string $property
37
     * @return mixed
38
     */
39
    public function __get($property)
40
    {
41
        if ($property === 'defaultLanguageCode') {
42
            @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...
43
                __CLASS__ . '::$defaultLanguageCode is deprecated. Use mainLanguageCode',
44
                E_USER_DEPRECATED
45
            );
46
47
            return $this->mainLanguageCode;
48
        }
49
50
        return parent::__get($property);
51
    }
52
53
    public function __isset($property)
54
    {
55
        if ($property === 'defaultLanguageCode') {
56
            @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...
57
                __CLASS__ . '::$defaultLanguageCode is deprecated. Use mainLanguageCode',
58
                E_USER_DEPRECATED
59
            );
60
61
            return true;
62
        }
63
64
        return parent::__isset($property);
65
    }
66
}
67