Problem Statement
The File class supports read, write, create, and remove, but has no way to copy or move a file. Users must manually read + write + remove to achieve this.
Proposed Solution
Add two methods:
copy(string $destination): File — copies the file to a new path, returns a new File instance for the copy
moveTo(string $destination): void — moves the file to a new path, updates the current instance's path
Alternatives Considered
- Only adding
copy() and implementing moveTo() as copy + remove
Breaking Change
No
Problem Statement
The
Fileclass supports read, write, create, and remove, but has no way to copy or move a file. Users must manually read + write + remove to achieve this.Proposed Solution
Add two methods:
copy(string $destination): File— copies the file to a new path, returns a newFileinstance for the copymoveTo(string $destination): void— moves the file to a new path, updates the current instance's pathAlternatives Considered
copy()and implementingmoveTo()as copy + removeBreaking Change
No