Skip to content

Commit a7dadf9

Browse files
committed
feat(File): Add essential methods for island management
- Implemented read() for full content retrieval - Added write() for full content persistence - Created getFileName() for name access - Added getFolder() for directory path access - These methods support robust island data handling
1 parent 062bf19 commit a7dadf9

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

  • src/imperazim/components/filesystem

src/imperazim/components/filesystem/File.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,27 @@ public function __construct(
5858
}
5959
}
6060

61+
// Add these new methods to support Island management
62+
public function read(): array {
63+
return $this->get(null, []);
64+
}
65+
66+
public function write(array $data): void {
67+
$extension = self::getExtensionByType($this->getFileType());
68+
$content = self::serializeContent($extension, $data);
69+
$this->writeFile($content);
70+
}
71+
72+
public function getFileName(): string {
73+
return $this->fileName;
74+
}
75+
76+
public function getFolder(): string {
77+
return $this->directoryOrConfig instanceof Config
78+
? dirname($this->directoryOrConfig->getPath())
79+
: $this->directoryOrConfig;
80+
}
81+
6182
/**
6283
* Clone the File object with empty data.
6384
* @return self

0 commit comments

Comments
 (0)