You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
1.5 KiB

  1. <?php namespace Wpstudio\AssetsManifest\Classes\Bundlers\Vite;
  2. use Illuminate\Support\Collection;
  3. class ViteEntrypoint
  4. {
  5. public string $file;
  6. public ?string $src;
  7. public ?bool $isEntry;
  8. public ?Collection $imports;
  9. public ?Collection $css;
  10. public function __construct(array $entrypoint)
  11. {
  12. $this->file = $entrypoint['file'];
  13. if (array_key_exists('src', $entrypoint)) {
  14. $this->isEntry = $entrypoint['src'];
  15. }
  16. if (array_key_exists('isEntry', $entrypoint)) {
  17. $this->isEntry = $entrypoint['isEntry'];
  18. }
  19. if (array_key_exists('imports', $entrypoint)) {
  20. $this->imports = collect($entrypoint['imports']);
  21. }
  22. if (array_key_exists('css', $entrypoint)) {
  23. $this->css = collect($entrypoint['css']);
  24. }
  25. }
  26. public function getIsEntry(): bool
  27. {
  28. if (isset($this->isEntry) && $this->isEntry) {
  29. return true;
  30. }
  31. return false;
  32. }
  33. public function hasImports()
  34. {
  35. return isset($this->imports) && $this->imports;
  36. }
  37. public function getImports(): Collection
  38. {
  39. return $this->imports;
  40. }
  41. public function hasCss()
  42. {
  43. return isset($this->css) && $this->css;
  44. }
  45. public function getCss(): Collection
  46. {
  47. return $this->css;
  48. }
  49. public function getFile(): string
  50. {
  51. return $this->file;
  52. }
  53. public function getSrc(): string
  54. {
  55. return $this->src;
  56. }
  57. }