Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
Line
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
1
 getHashCode
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 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 * @license     http://www.gnu.org/licenses/lgpl.txt LGPL version 3
16 */
17
18declare(strict_types=1);
19
20namespace PhpOffice\PhpPresentation\Shape;
21
22use PhpOffice\PhpPresentation\AbstractShape;
23use PhpOffice\PhpPresentation\ComparableInterface;
24use PhpOffice\PhpPresentation\Style\Border;
25
26/**
27 * Line shape.
28 */
29class Line extends AbstractShape implements ComparableInterface
30{
31    /**
32     * Create a new \PhpOffice\PhpPresentation\Shape\Line instance.
33     *
34     * @param int $fromX
35     * @param int $fromY
36     * @param int $toX
37     * @param int $toY
38     */
39    public function __construct($fromX, $fromY, $toX, $toY)
40    {
41        parent::__construct();
42        $this->getBorder()->setLineStyle(Border::LINE_SINGLE);
43
44        $this->setOffsetX($fromX);
45        $this->setOffsetY($fromY);
46        $this->setWidth($toX - $fromX);
47        $this->setHeight($toY - $fromY);
48    }
49
50    /**
51     * Get hash code.
52     *
53     * @return string Hash code
54     */
55    public function getHashCode(): string
56    {
57        return md5($this->getBorder()->getLineStyle() . parent::getHashCode() . __CLASS__);
58    }
59}