src/MadeYourDay/SVG/Document.php
public function getViewBox(){

		if(!empty($this->xmlDocument['viewBox'])){

			$viewBox = $this->getValuesFromList($this->xmlDocument['viewBox']);
			if(count($viewBox) !== 4){
				return null;
			}
			return array(
				'x' => $viewBox[0]*1,
				'y' => $viewBox[1]*1,
				'width' => $viewBox[2]*1,
				'height' => $viewBox[3]*1,
			);

		}

		if(!empty($this->xmlDocument['width']) && !empty($this->xmlDocument['height'])){

			$width = trim($this->xmlDocument['width']);
			$height = trim($this->xmlDocument['height']);
			if(isset($this->unitInPixels[substr($width, -2)])){
				$width = $width*$this->unitInPixels[substr($width, -2)];
			}
			if(isset($this->unitInPixels[substr($height, -2)])){
				$height = $height*$this->unitInPixels[substr($height, -2)];
			}
			return array(
				'x' => 0,
				'y' => 0,
				'width' => $width*1,
				'height' => $height*1,
			);

		}

		return null;

	}
public function getViewBox(){

		if(!empty($this->xmlDocument['viewBox'])){

			$viewBox = $this->getValuesFromList($this->xmlDocument['viewBox']);
			if(count($viewBox) !== 4){
				return null;
			}
			return array(
				'x' => $viewBox[0]*1,
				'y' => $viewBox[1]*1,
				'width' => $viewBox[2]*1,
				'height' => $viewBox[3]*1,
			);

		}

		if(!empty($this->xmlDocument['width']) && !empty($this->xmlDocument['height'])){

			$width = trim($this->xmlDocument['width']);
			$height = trim($this->xmlDocument['height']);
			if(isset($this->unitInPixels[substr($width, -2)])){
				$width = $width*$this->unitInPixels[substr($width, -2)];
			}
			if(isset($this->unitInPixels[substr($height, -2)])){
				$height = $height*$this->unitInPixels[substr($height, -2)];
			}
			return array(
				'x' => 0,
				'y' => 0,
				'width' => $width*1,
				'height' => $height*1,
			);

		}

		return null;

	}
public function getViewBox ( ) { if ( ! empty ( $ this -> xmlDocument [ 'viewBox' ] ) ) { $ viewBox = $ this -> getValuesFromList ( $ this -> xmlDocument [ 'viewBox' ] ) ; if ( count ( $ viewBox ) !== 4 ) { return null ; } return array ( 'x' => $ viewBox [ 0 ] * 1 , 'y' => $ viewBox [ 1 ] * 1 , 'width' => $ viewBox [ 2 ] * 1 , 'height' => $ viewBox [ 3 ] * 1 , ) ; } if ( ! empty ( $ this -> xmlDocument [ 'width' ] ) && ! empty ( $ this -> xmlDocument [ 'height' ] ) ) { $ width = trim ( $ this -> xmlDocument [ 'width' ] ) ; $ height = trim ( $ this -> xmlDocument [ 'height' ] ) ; if ( isset ( $ this -> unitInPixels [ substr ( $ width , - 2 ) ] ) ) { $ width = $ width * $ this -> unitInPixels [ substr ( $ width , - 2 ) ] ; } if ( isset ( $ this -> unitInPixels [ substr ( $ height , - 2 ) ] ) ) { $ height = $ height * $ this -> unitInPixels [ substr ( $ height , - 2 ) ] ; } return array ( 'x' => 0 , 'y' => 0 , 'width' => $ width * 1 , 'height' => $ height * 1 , ) ; } return null ; }
returns an viewbox array containing x/y offsets and with/height

@return array|null array with x,y,width,height values
returns an viewbox array containing x / y offsets and with / height