Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace Icon;
- /**
- * Simple helper class that outputs
- * svg icons as text
- */
- class Icon
- {
- /**
- * Path where the icons are stored
- * @var string
- */
- private $directory = '';
- const FILE_EXTENSION = '.svg';
- /**
- * @param string $directory
- */
- public function __construct(string $directory = '')
- {
- $this->directory = $directory;
- }
- /**
- * Returns the contents of the svg file
- * @param string $file
- * @return string
- */
- public function render(string $file)
- {
- return file_get_contents($this->directory . $file . self::FILE_EXTENSION);
- }
- }
- /* demo usage */
- $icon = new Icon(__DIR__.'/icons/');
- echo $icon->render('cat');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement