Advertisement
Guest User

Untitled

a guest
Aug 24th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. <?php
  2.  
  3. namespace Icon;
  4.  
  5. /**
  6. * Simple helper class that outputs
  7. * svg icons as text
  8. */
  9. class Icon
  10. {
  11. /**
  12. * Path where the icons are stored
  13. * @var string
  14. */
  15. private $directory = '';
  16. const FILE_EXTENSION = '.svg';
  17.  
  18. /**
  19. * @param string $directory
  20. */
  21. public function __construct(string $directory = '')
  22. {
  23. $this->directory = $directory;
  24. }
  25.  
  26. /**
  27. * Returns the contents of the svg file
  28. * @param string $file
  29. * @return string
  30. */
  31. public function render(string $file)
  32. {
  33. return file_get_contents($this->directory . $file . self::FILE_EXTENSION);
  34. }
  35. }
  36.  
  37. /* demo usage */
  38. $icon = new Icon(__DIR__.'/icons/');
  39.  
  40. echo $icon->render('cat');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement