<?php

namespace Hecate;

class Icon {

	public static function get( $name = '' ) {
		$parts = explode( '/', $name );
		if ( count( $parts ) !== 2 ) {
			return '';
		}

		$packageName = $parts[0];
		$iconName    = $parts[1];
		$iconPah     = strtr(
			':root\assets\svg\:package\:icon.svg',
			array(
				':root'    => HECATE_ROOT,
				':package' => $packageName,
				':icon'    => $iconName,
			)
		);
		if ( ! file_exists( $iconPah ) ) {
			return '';
		}

		$icon = file_get_contents( $iconPah );
		$icon = '<!--Icon by Font Awesome (https://fontawesome.com)-->' . $icon;
		return $icon;
	}
}
