Completed
Push — master ( c616f0...8421f8 )
by Vincenzo
03:02
created

MatchResult::castAttributes()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 2
eloc 4
nc 2
nop 1
1
<?php
2
3
namespace App\Lib\DsManager\Models\Orm;
4
5
/**
6
 * Class MatchResult
7
 * @package App\Lib\DsManager\Models\Orm
8
 */
9
class MatchResult extends Match
10
{
11
    /**
12
     * @var array
13
     */
14
    protected $fillable = [
15
        'goal_home',
16
        'goal_away',
17
        'info',
18
        'simulated'
19
    ];
20
21
    protected $hidden = [
22
        'home_team_id',
23
        'away_team_id',
24
        'created_at',
25
        'updated_at'
26
    ];
27
28
    /**
29
     * @var array
30
     */
31
    protected $casts = [
32
        'info' => 'json',
33
        'simulated' => 'boolean'
34
    ];
35
36
    public static function castAttributes($attributes = [])
37
    {
38
        if (array_key_exists('info', $attributes)) {
39
            $attributes['info'] = json_encode($attributes['info']);
40
        }
41
        return $attributes;
42
    }
43
}