Code Duplication    Length = 26-28 lines in 2 locations

src/Entry/EntryTranslationsModel.php 1 location

@@ 111-136 (lines=26) @@
108
     * @param string $key
109
     * @param mixed  $value
110
     */
111
    public function setAttribute($key, $value)
112
    {
113
        if (!$parent = $this->getParent()) {
114
            return null;
115
        }
116
117
        /* @var AssignmentInterface $assignment */
118
        $assignment = $parent->getAssignment($key);
119
120
        if (!$assignment) {
121
            parent::setAttribute($key, $value);
122
123
            return;
124
        }
125
126
        $type = $assignment->getFieldType($this);
127
128
        $type->setEntry($this);
129
        $type->setLocale($this->locale);
130
131
        $accessor = $type->getAccessor();
132
        $modifier = $type->getModifier();
133
134
        $accessor->set($modifier->modify($value));
135
    }
136
137
    /**
138
     * Fire field type events.
139
     *

src/Entry/EntryModel.php 1 location

@@ 297-324 (lines=28) @@
294
     * @param  $fieldSlug
295
     * @return null|FieldType
296
     */
297
    public function getFieldType($fieldSlug)
298
    {
299
        $locale = config('app.locale');
300
301
        $assignment = $this->getAssignment($fieldSlug);
302
303
        if (!$assignment) {
304
            return null;
305
        }
306
307
        $type = $assignment->getFieldType();
308
309
        if ($assignment->isTranslatable()) {
310
            $entry = $this->translateOrDefault($locale);
311
312
            $type->setLocale($locale);
313
        } else {
314
            $entry = $this;
315
        }
316
317
        $type->setEntry($entry);
318
319
        $type->setValue($this->getFieldValue($fieldSlug));
320
        $type->setEntry($this);
321
322
        return $type;
323
    }
324
325
    /**
326
     * Get the field type query.
327
     *