Panel   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 27
ccs 0
cts 9
cp 0
rs 10
c 0
b 0
f 0
eloc 8
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A validateWidth() 0 4 2
A width() 0 3 1
A setWidth() 0 7 1
1
<?php
2
3
namespace Terranet\Administrator\Dashboard;
4
5
use Terranet\Administrator\Contracts\Services\Widgetable;
6
7
abstract class Panel implements Widgetable
8
{
9
    protected $width = 6;
10
11
    public function setWidth($width = 6)
12
    {
13
        $this->validateWidth($width);
14
15
        $this->width = (int) $width;
16
17
        return $this;
18
    }
19
20
    public function width()
21
    {
22
        return $this->width;
23
    }
24
25
    /**
26
     * @param $width
27
     *
28
     * @throws \Exception
29
     */
30
    protected function validateWidth($width)
31
    {
32
        if (!\in_array($width, range(1, 12, 1), true)) {
33
            throw new \Exception('Width must be between 1 and 12.');
34
        }
35
    }
36
}
37