Rectangle   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 0
dl 0
loc 47
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getArea() 0 4 1
A getHeight() 0 4 1
A getWidth() 0 4 1
A __construct() 0 5 3
1
<?php
2
/**
3
 * Grandstream-XMLApp
4
 *
5
 * Copyright (c) 2017 pudelek.org.pl
6
 *
7
 * @license MIT License (MIT)
8
 *
9
 * For the full copyright and license information, please view source file
10
 * that is bundled with this package in the file LICENSE
11
 *
12
 * @author  Marcin Pudełek <[email protected]>
13
 */
14
15
namespace mrcnpdlk\Grandstream\XMLApp\Helper;
16
17
/**
18
 * Class Rectangle
19
 *
20
 * @package mrcnpdlk\Grandstream\XMLApp\Helper
21
 */
22
class Rectangle
23
{
24
    /**
25
     * @var int
26
     */
27
    private $iWidth;
28
    /**
29
     * @var int
30
     */
31
    private $iHeight;
32
33
    /**
34
     * Rectangle constructor.
35
     *
36
     * @param int      $w
37
     * @param int|null $h
38
     */
39 4
    public function __construct(int $w, int $h = null)
40
    {
41 4
        $this->iWidth  = $w < 0 ? 0 : $w;
42 4
        $this->iHeight = $h < 0 ? 0 : ($h ?? $this->iWidth);
43 4
    }
44
45
    /**
46
     * @return int
47
     */
48 3
    public function getArea()
49
    {
50 3
        return $this->getHeight() * $this->getWidth();
51
    }
52
53
    /**
54
     * @return int
55
     */
56 3
    public function getHeight()
57
    {
58 3
        return $this->iHeight;
59
    }
60
61
    /**
62
     * @return int
63
     */
64 3
    public function getWidth()
65
    {
66 3
        return $this->iWidth;
67
    }
68
}
69