Code Duplication    Length = 100-100 lines in 2 locations

eZ/Publish/Core/REST/Client/Values/User/User.php 1 location

@@ 20-119 (lines=100) @@
17
 *
18
 * @see \eZ\Publish\API\Repository\Values\User\User
19
 */
20
class User extends APIUser
21
{
22
    /**
23
     * @var \eZ\Publish\API\Repository\Values\Content\Content
24
     */
25
    protected $content;
26
27
    /**
28
     * Returns the VersionInfo for this version.
29
     *
30
     * @return \eZ\Publish\API\Repository\Values\Content\VersionInfo
31
     */
32
    public function getVersionInfo()
33
    {
34
        return $this->content->getVersionInfo();
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function getName($languageCode = null)
41
    {
42
        return $this->content->getVersionInfo()->getName($languageCode);
43
    }
44
45
    /**
46
     * Returns a field value for the given value
47
     * $version->fields[$fieldDefId][$languageCode] is an equivalent call
48
     * if no language is given on a translatable field this method returns
49
     * the value of the initial language of the version if present, otherwise null.
50
     * On non translatable fields this method ignores the languageCode parameter.
51
     *
52
     * @param string $fieldDefIdentifier
53
     * @param string $languageCode
54
     *
55
     * @return mixed a primitive type or a field type Value object depending on the field type.
56
     */
57
    public function getFieldValue($fieldDefIdentifier, $languageCode = null)
58
    {
59
        return $this->content->getFieldValue($fieldDefIdentifier, $languageCode);
60
    }
61
62
    /**
63
     * This method returns the complete fields collection.
64
     *
65
     * @return \eZ\Publish\API\Repository\Values\Content\Field[]
66
     */
67
    public function getFields()
68
    {
69
        return $this->content->getFields();
70
    }
71
72
    /**
73
     * This method returns the fields for a given language and non translatable fields.
74
     *
75
     * If note set the initialLanguage of the content version is used.
76
     *
77
     * @param string $languageCode
78
     *
79
     * @return \eZ\Publish\API\Repository\Values\Content\Field[] With field identifier as keys
80
     */
81
    public function getFieldsByLanguage($languageCode = null)
82
    {
83
        return $this->content->getFieldsByLanguage($languageCode);
84
    }
85
86
    /**
87
     * This method returns the field for a given field definition identifier and language.
88
     *
89
     * If not set the initialLanguage of the content version is used.
90
     *
91
     * @param string $fieldDefIdentifier
92
     * @param string|null $languageCode
93
     *
94
     * @return \eZ\Publish\API\Repository\Values\Content\Field|null A {@link Field} or null if nothing is found
95
     */
96
    public function getField($fieldDefIdentifier, $languageCode = null)
97
    {
98
        return $this->content->getField($fieldDefIdentifier, $languageCode);
99
    }
100
101
    public function __get($property)
102
    {
103
        switch ($property) {
104
            case 'contentInfo':
105
                return $this->content->contentInfo;
106
107
            case 'id':
108
                return $this->content->id;
109
110
            case 'versionInfo':
111
                return $this->getVersionInfo();
112
113
            case 'fields':
114
                return $this->getFields();
115
        }
116
117
        return parent::__get($property);
118
    }
119
}
120

eZ/Publish/Core/REST/Client/Values/User/UserGroup.php 1 location

@@ 20-119 (lines=100) @@
17
 *
18
 * @see \eZ\Publish\API\Repository\Values\User\UserGroup
19
 */
20
class UserGroup extends APIUserGroup
21
{
22
    /**
23
     * @var \eZ\Publish\API\Repository\Values\Content\Content
24
     */
25
    protected $content;
26
27
    /**
28
     * Returns the VersionInfo for this version.
29
     *
30
     * @return \eZ\Publish\API\Repository\Values\Content\VersionInfo
31
     */
32
    public function getVersionInfo()
33
    {
34
        return $this->content->getVersionInfo();
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function getName($languageCode = null)
41
    {
42
        return $this->content->getVersionInfo()->getName($languageCode);
43
    }
44
45
    /**
46
     * Returns a field value for the given value
47
     * $version->fields[$fieldDefId][$languageCode] is an equivalent call
48
     * if no language is given on a translatable field this method returns
49
     * the value of the initial language of the version if present, otherwise null.
50
     * On non translatable fields this method ignores the languageCode parameter.
51
     *
52
     * @param string $fieldDefIdentifier
53
     * @param string $languageCode
54
     *
55
     * @return mixed a primitive type or a field type Value object depending on the field type.
56
     */
57
    public function getFieldValue($fieldDefIdentifier, $languageCode = null)
58
    {
59
        return $this->content->getFieldValue($fieldDefIdentifier, $languageCode);
60
    }
61
62
    /**
63
     * This method returns the complete fields collection.
64
     *
65
     * @return \eZ\Publish\API\Repository\Values\Content\Field[]
66
     */
67
    public function getFields()
68
    {
69
        return $this->content->getFields();
70
    }
71
72
    /**
73
     * This method returns the fields for a given language and non translatable fields.
74
     *
75
     * If note set the initialLanguage of the content version is used.
76
     *
77
     * @param string $languageCode
78
     *
79
     * @return \eZ\Publish\API\Repository\Values\Content\Field[] With field identifier as keys
80
     */
81
    public function getFieldsByLanguage($languageCode = null)
82
    {
83
        return $this->content->getFieldsByLanguage($languageCode);
84
    }
85
86
    /**
87
     * This method returns the field for a given field definition identifier and language.
88
     *
89
     * If not set the initialLanguage of the content version is used.
90
     *
91
     * @param string $fieldDefIdentifier
92
     * @param string|null $languageCode
93
     *
94
     * @return \eZ\Publish\API\Repository\Values\Content\Field|null A {@link Field} or null if nothing is found
95
     */
96
    public function getField($fieldDefIdentifier, $languageCode = null)
97
    {
98
        return $this->content->getField($fieldDefIdentifier, $languageCode);
99
    }
100
101
    public function __get($property)
102
    {
103
        switch ($property) {
104
            case 'contentInfo':
105
                return $this->content->contentInfo;
106
107
            case 'id':
108
                return $this->content->id;
109
110
            case 'versionInfo':
111
                return $this->getVersionInfo();
112
113
            case 'fields':
114
                return $this->getFields();
115
        }
116
117
        return parent::__get($property);
118
    }
119
}
120