SeatMap   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
dl 0
loc 28
rs 10
c 1
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A events() 0 3 1
A getRowsAndColumns() 0 19 3
1
<?php
2
3
namespace App;
4
5
use Illuminate\Database\Eloquent\Model;
6
7
class SeatMap extends Model
8
{
9
    protected $fillable = ['seats', 'name', 'description', 'layout'];
10
11
    public function events()
12
    {
13
        return $this->hasMany('App\Event');
14
    }
15
16
    public function getRowsAndColumns()
17
    {
18
        if(!$this->layout) {
19
            return null;
20
        }
21
22
        $result = [];
23
24
        $rows = json_decode($this->layout);
25
        $result['rows'] = count($rows);
26
        $result['columns'] = array_reduce($rows, function($intermediate, $row) {
27
            $columns = strlen($row);
28
            if($intermediate < $columns) {
29
                return $columns;
30
            } else {
31
                return $intermediate;
32
            }
33
        }, 0);
34
        return $result;
35
    }
36
}
37