PHP: Find the width and height of an SVG image in PHP

SVG is "Scalable Vector Graphics", and in principle you can scale to infinity. For example, I always use the logo in SVG format to make it look sharp and nice. When I insert logo with svg as an img element, where I would like to set width and height ratio attributes.

For this purpose I made a php function that works with transients that save the data for the logo, you can use the following php function that makes an array with a lot of data, including width and height. Here is a straight snippet of it:

	$data['logo']['img'] = get_template_directory_uri() . get_option('logo'); // we retrieve the logo file and save the url to the image
	$svgdata =(simplexml_load_file(get_template_directory_uri() . get_option('logo'))); //We retrieve all data on the svg image with simplexml_load_file
	$data['logo']['size'] = ['width' => strval($svgdata->attributes()->width), 'height' => strval($svgdata->attributes()->height)]; // we store the height and width of the svg image in an array. strval returns the string values of the parameter passed to it instead of an inner array or object.