File.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. namespace inter\phpStruct;
  3. class File
  4. {
  5. private string $fileName;
  6. private string $namespace;
  7. /** @var string[] */
  8. private array $uses = [];
  9. /** @var PHPClass[] */
  10. private array $classes;
  11. private string $path;
  12. public function SetFileName(string $fileName): self
  13. {
  14. $this->fileName = $fileName;
  15. return $this;
  16. }
  17. public function GetFileName(): string
  18. {
  19. return $this->fileName . ".php";
  20. }
  21. public function SetNamespace(string $namespace): self
  22. {
  23. $this->namespace = $namespace;
  24. return $this;
  25. }
  26. public function GetNamespace(): string
  27. {
  28. return $this->namespace;
  29. }
  30. public function AddClass(PHPClass $class): self
  31. {
  32. $this->classes[] = $class;
  33. return $this;
  34. }
  35. /**
  36. * @return PHPClass[]
  37. */
  38. public function GetClasses(): array
  39. {
  40. return $this->classes;
  41. }
  42. public function SetPath(string $path): self
  43. {
  44. $this->path = $path;
  45. return $this;
  46. }
  47. public function GetPath(): string
  48. {
  49. return $this->path;
  50. }
  51. /**
  52. * 获取文件的创建时间
  53. */
  54. public function GetFileCreateTime(): string
  55. {
  56. return date("Y-m-d H:i:s");
  57. }
  58. public function AddUse(string $use): self
  59. {
  60. $this->uses[] = $use;
  61. return $this;
  62. }
  63. public function SetUses(array $uses): self
  64. {
  65. $this->uses = $uses;
  66. return $this;
  67. }
  68. /**
  69. * @return string[]
  70. */
  71. public function GetUses(): array
  72. {
  73. return $this->uses;
  74. }
  75. }