Completed
Pull Request — develop (#435)
by
unknown
19:30 queued 15:48
created

Triangle   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 34
ccs 0
cts 14
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 1
A getHashCode() 0 4 1
1
<?php
2
/**
3
 * @author Muhammad Hasan Shahid <[email protected]>
4
 * Mindline Analytics Gmbh
5
 */
6
7
namespace PhpOffice\PhpPresentation\Shape;
8
9
use PhpOffice\PhpPresentation\AbstractShape;
10
use PhpOffice\PhpPresentation\ComparableInterface;
11
use PhpOffice\PhpPresentation\Style\Border;
12
13
14
/**
15
 * Class Triangle
16
 * @package PhpOffice\PhpPresentation\Shape
17
 * Make shape triangle
18
 */
19
class Triangle extends AbstractShape implements ComparableInterface
20
{
21
    /**
22
     * Create a new \PhpOffice\PhpPresentation\Shape\Triangle instance
23
     *
24
     * @param int $fromX
25
     * @param int $fromY
26
     * @param int $toX
27
     * @param int $toY
28
     * @param int $rotation used for rotation clockwise or anti-clockwise
29
     */
30
    public function __construct($fromX, $fromY, $toX, $toY, $rotation)
31
    {
32
        parent::__construct();
33
        $this->getBorder()->setLineStyle(Border::LINE_SINGLE);
34
35
        $this->setOffsetX($fromX);
36
        $this->setOffsetY($fromY);
37
        $this->setWidth($toX - $fromX);
38
        $this->setHeight($toY - $fromY);
39
        $this->setRotation($rotation);
40
    }
41
42
    /**
43
     * Get hash code
44
     *
45
     * @return string Hash code
46
     */
47
    public function getHashCode()
48
    {
49
        return md5($this->getBorder()->getLineStyle() . parent::getHashCode() . __CLASS__);
50
    }
51
52
}
53