Code Duplication    Length = 26-28 lines in 2 locations

src/Entry/EntryTranslationsModel.php 1 location

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

src/Entry/EntryModel.php 1 location

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