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

@@ 322-349 (lines=28) @@
319
     * @param  $fieldSlug
320
     * @return null|FieldType
321
     */
322
    public function getFieldType($fieldSlug)
323
    {
324
        $locale = config('app.locale');
325
326
        $assignment = $this->getAssignment($fieldSlug);
327
328
        if (!$assignment) {
329
            return null;
330
        }
331
332
        $type = $assignment->getFieldType();
333
334
        if ($assignment->isTranslatable()) {
335
            $entry = $this->translateOrDefault($locale);
336
337
            $type->setLocale($locale);
338
        } else {
339
            $entry = $this;
340
        }
341
342
        $type->setEntry($entry);
343
344
        $type->setValue($this->getFieldValue($fieldSlug));
345
        $type->setEntry($this);
346
347
        return $type;
348
    }
349
350
    /**
351
     * Get the field type query.
352
     *