Differences Between: [Versions 310 and 311] [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]
1 <?php 2 3 namespace PhpOffice\PhpSpreadsheet\Worksheet; 4 5 use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; 6 7 class Drawing extends BaseDrawing 8 { 9 /** 10 * Path. 11 * 12 * @var string 13 */ 14 private $path; 15 16 /** 17 * Create a new Drawing. 18 */ 19 public function __construct() 20 { 21 // Initialise values 22 $this->path = ''; 23 24 // Initialize parent 25 parent::__construct(); 26 } 27 28 /** 29 * Get Filename. 30 * 31 * @return string 32 */ 33 public function getFilename() 34 { 35 return basename($this->path); 36 } 37 38 /** 39 * Get indexed filename (using image index). 40 * 41 * @return string 42 */ 43 public function getIndexedFilename() 44 { 45 $fileName = $this->getFilename(); 46 $fileName = str_replace(' ', '_', $fileName); 47 48 return str_replace('.' . $this->getExtension(), '', $fileName) . $this->getImageIndex() . '.' . $this->getExtension(); 49 } 50 51 /** 52 * Get Extension. 53 * 54 * @return string 55 */ 56 public function getExtension() 57 { 58 $exploded = explode('.', basename($this->path)); 59 60 return $exploded[count($exploded) - 1]; 61 } 62 63 /** 64 * Get Path. 65 * 66 * @return string 67 */ 68 public function getPath() 69 { 70 return $this->path; 71 } 72 73 /** 74 * Set Path. 75 * 76 * @param string $pValue File path 77 * @param bool $pVerifyFile Verify file 78 * 79 * @return $this 80 */ 81 public function setPath($pValue, $pVerifyFile = true) 82 { 83 if ($pVerifyFile) { 84 if (file_exists($pValue)) { 85 $this->path = $pValue; 86 87 if ($this->width == 0 && $this->height == 0) { 88 // Get width/height 89 [$this->width, $this->height] = getimagesize($pValue); 90 } 91 } else { 92 throw new PhpSpreadsheetException("File $pValue not found!"); 93 } 94 } else { 95 $this->path = $pValue; 96 } 97 98 return $this; 99 } 100 101 /** 102 * Get hash code. 103 * 104 * @return string Hash code 105 */ 106 public function getHashCode() 107 { 108 return md5( 109 $this->path . 110 parent::getHashCode() . 111 __CLASS__ 112 ); 113 } 114 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body