Polygon   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 3
c 1
b 0
f 0
dl 0
loc 30
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A set() 0 3 1
A get() 0 3 1
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
}