Code Duplication    Length = 17-21 lines in 2 locations

src/hal/EmbeddableTrait.php 2 locations

@@ 103-119 (lines=17) @@
100
     * field names, and the array values are the corresponding object property
101
     * names or PHP callables returning the field values.
102
     */
103
    protected function resolveFieldList($fields): array
104
    {
105
        $fields = $this->extractRootFields($fields);
106
        $result = [];
107
108
        foreach ($this->fields() as $field => $definition) {
109
                if (is_int($field)) {
110
                    $field = $definition;
111
                }
112
113
                if (empty($fields) || in_array($field, $fields, true)) {
114
                    $result[$field] = $definition;
115
                }
116
        }
117
118
        return $result;
119
    }
120
121
    /**
122
     * Determines which expand fields can be returned by [[toArray()]].
@@ 132-152 (lines=21) @@
129
     * field names, and the array values are the corresponding object property
130
     * names or PHP callables returning the field values.
131
     */
132
    protected function resolveExpandList($expand): array
133
    {
134
        if (empty($expand)) {
135
            return [];
136
        }
137
138
        $fields = $this->extractRootFields($expand);
139
        $result = [];
140
141
        foreach ($this->extraFields() as $field => $definition) {
142
                if (is_int($field)) {
143
                    $field = $definition;
144
                }
145
146
                if (in_array($field, $fields, true)) {
147
                    $result[$field] = $definition;
148
                }
149
        }
150
151
        return $result;
152
    }
153
154
    /**
155
     * @param string $field name of the field to be resolved.