Completed
Pull Request — develop (#207)
by Franck
24:36 queued 20:39
created

Drawing::setPath()   B

Complexity

Conditions 5
Paths 4

Size

Total Lines 19
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 5

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 19
ccs 12
cts 12
cp 1
rs 8.8571
cc 5
eloc 11
nc 4
nop 2
crap 5
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
 * @link        https://github.com/PHPOffice/PHPPresentation
14
 * @copyright   2009-2015 PHPPresentation contributors
15
 * @license     http://www.gnu.org/licenses/lgpl.txt LGPL version 3
16
 */
17
18
namespace PhpOffice\PhpPresentation\Shape;
19
20
use PhpOffice\PhpPresentation\ComparableInterface;
21
22
/**
23
 * Drawing element
24
 */
25
class Drawing extends AbstractGraphic implements ComparableInterface
26
{
27
    /**
28
     * Path
29
     *
30
     * @var string
31
     */
32
    private $path;
33
34
    /**
35
     * Create a new \PhpOffice\PhpPresentation\Slide\Drawing
36
     */
37 34
    public function __construct()
38
    {
39
        // Initialise values
40 34
        $this->path = '';
41
42
        // Initialize parent
43 34
        parent::__construct();
44 34
    }
45
46
    /**
47
     * Get Filename
48
     *
49
     * @return string
50
     */
51 9
    public function getFilename()
52
    {
53 9
        return basename($this->path);
54
    }
55
56
    /**
57
     * Get indexed filename (using image index)
58
     *
59
     * @return string
60
     */
61 7
    public function getIndexedFilename()
62
    {
63 7
        return str_replace('.' . $this->getExtension(), '', $this->getFilename()) . $this->getImageIndex() . '.' . $this->getExtension();
64
    }
65
66
    /**
67
     * Get Extension
68
     *
69
     * @return string
70
     */
71 18
    public function getExtension()
72
    {
73 18
        $exploded = explode(".", basename($this->path));
74
75 18
        return $exploded[count($exploded) - 1];
76
    }
77
78
    /**
79
     * Get hash code
80
     *
81
     * @return string Hash code
82
     */
83 23
    public function getHashCode()
84
    {
85 23
        return md5($this->path . parent::getHashCode() . __CLASS__);
86
    }
87
}
88