Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
8 / 8
Line
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
8 / 8
 __construct
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
7 / 7
 getHashCode
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
1<?php
2/**
3 * This file is part of PHPPresentation - A pure PHP library for reading and writing
4 * presentations documents.
5 *
6 * PHPPresentation is free software distributed under the terms of the GNU Lesser
7 * General Public License version 3 as published by the Free Software Foundation.
8 *
9 * For the full copyright and license information, please read the LICENSE
10 * file that was distributed with this source code. For the full list of
11 * contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
12 *
13 * @see        https://github.com/PHPOffice/PHPPresentation
14 *
15 * @copyright   2009-2015 PHPPresentation contributors
16 * @license     http://www.gnu.org/licenses/lgpl.txt LGPL version 3
17 */
18
19declare(strict_types=1);
20
21namespace PhpOffice\PhpPresentation\Shape;
22
23use PhpOffice\PhpPresentation\AbstractShape;
24use PhpOffice\PhpPresentation\ComparableInterface;
25use PhpOffice\PhpPresentation\Style\Border;
26
27/**
28 * Line shape.
29 */
30class Line extends AbstractShape implements ComparableInterface
31{
32    /**
33     * Create a new \PhpOffice\PhpPresentation\Shape\Line instance.
34     *
35     * @param int $fromX
36     * @param int $fromY
37     * @param int $toX
38     * @param int $toY
39     */
40    public function __construct($fromX, $fromY, $toX, $toY)
41    {
42        parent::__construct();
43        $this->getBorder()->setLineStyle(Border::LINE_SINGLE);
44
45        $this->setOffsetX($fromX);
46        $this->setOffsetY($fromY);
47        $this->setWidth($toX - $fromX);
48        $this->setHeight($toY - $fromY);
49    }
50
51    /**
52     * Get hash code.
53     *
54     * @return string Hash code
55     */
56    public function getHashCode(): string
57    {
58        return md5($this->getBorder()->getLineStyle() . parent::getHashCode() . __CLASS__);
59    }
60}