Polygon::set()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 4
1
<?php
2
namespace SimpleCMS\Region\Casts;
3
4
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
5
6
class Polygon implements CastsAttributes
7
{
8
9
    /**
10
     * Transform the attribute from the underlying model values.
11
     * 
12
     * @param  \Illuminate\Database\Eloquent\Model  $model
13
     * @param  string  $key
14
     * @param  mixed  $value
15
     * @param  array<string, mixed>  $attributes
16
     * @return mixed
17
     */
18
    public function get($model, $key, $value, $attributes)
19
    {
20
        return json_decode($value, true);
21
    }
22
23
24
    /**
25
     * Transform the attribute to its underlying model values.
26
     *
27
     * @param  \Illuminate\Database\Eloquent\Model  $model
28
     * @param  string  $key
29
     * @param  mixed  $value
30
     * @param  array<string, mixed>  $attributes
31
     * @return mixed
32
     */
33
    public function set($model, $key, $value, $attributes)
34
    {
35
        return json_encode($value);
36
    }
37
}