Interfaces
3 weeks ago
trait-bufferedwritestreamviaputcontents.php
3 weeks ago
trait-copydirectoryrecursive.php
3 weeks ago
trait-copyfileviastreaming.php
3 weeks ago
trait-copyrecursiveviastreaming.php
3 weeks ago
trait-getcontentsviareadstream.php
3 weeks ago
trait-internalizewritestream.php
3 weeks ago
trait-mkdirrecursive.php
3 weeks ago
trait-putcontentsviawritestream.php
3 weeks ago
trait-readonlyfilesystem.php
3 weeks ago
trait-renamefileviacopyandrm.php
3 weeks ago
trait-rmdirrecursive.php
3 weeks ago
trait-renamefileviacopyandrm.php
21 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WordPress\Filesystem\Mixin; |
| 4 | |
| 5 | use WordPress\Filesystem\FilesystemException; |
| 6 | |
| 7 | /** |
| 8 | * Implements rename() for files using the copy() and rm() methods. |
| 9 | */ |
| 10 | trait RenameFileViaCopyAndRm { |
| 11 | |
| 12 | public function rename( $from_path, $to_path, $options = array() ) { |
| 13 | if ( ! $this->is_file( $from_path ) ) { |
| 14 | throw new FilesystemException( sprintf( 'Path is not a file: %s', $from_path ) ); |
| 15 | } |
| 16 | |
| 17 | $this->copy( $from_path, $to_path, $options ); |
| 18 | $this->rm( $from_path ); |
| 19 | } |
| 20 | } |
| 21 |