Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
4 / 4 |
|
100.00% |
4 / 4 |
CRAP | |
100.00% |
1 / 1 |
| AbstractEntry | |
100.00% |
4 / 4 |
|
100.00% |
4 / 4 |
5 | |
100.00% |
1 / 1 |
| moveTo | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
2 | |||
| copyTo | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
| delete | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
| isEncrypted | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getPath | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| __toString | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * File handler class. |
| 5 | * |
| 6 | * This Source Code Form is subject to the terms of the Mozilla Public License, |
| 7 | * v. 2.0. If a copy of the MPL was not distributed with this file, You can |
| 8 | * obtain one at https://mozilla.org/MPL/2.0/. |
| 9 | * |
| 10 | * @package phpMyFAQ |
| 11 | * @author Anatoliy Belsky <ab@php.net> |
| 12 | * @copyright 2009-2026 phpMyFAQ Team |
| 13 | * @license https://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0 |
| 14 | * @link https://www.phpmyfaq.de |
| 15 | * @since 2009-08-21 |
| 16 | */ |
| 17 | |
| 18 | declare(strict_types=1); |
| 19 | |
| 20 | namespace phpMyFAQ\Attachment\Filesystem; |
| 21 | |
| 22 | /** |
| 23 | * Class Entry |
| 24 | * |
| 25 | * @package phpMyFAQ\Attachment\Filesystem |
| 26 | */ |
| 27 | abstract class AbstractEntry implements \Stringable |
| 28 | { |
| 29 | /** |
| 30 | * Path to the entry in the filesystem. |
| 31 | */ |
| 32 | protected string $path; |
| 33 | |
| 34 | /** |
| 35 | * This opened handle. |
| 36 | * |
| 37 | * @var resource |
| 38 | */ |
| 39 | public $handle; |
| 40 | |
| 41 | /** |
| 42 | * Move a file to another location. |
| 43 | * |
| 44 | * @param object|string $entry an entry to move to |
| 45 | */ |
| 46 | public function moveTo(object|string $entry): bool |
| 47 | { |
| 48 | return $this->copyTo($entry) && $this->delete(); |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Copy file to another location. |
| 53 | * |
| 54 | * @param object|string $entry an entry to copy to |
| 55 | */ |
| 56 | abstract public function copyTo(object|string $entry): bool; |
| 57 | |
| 58 | /** |
| 59 | * Delete this file. |
| 60 | */ |
| 61 | abstract public function delete(): bool; |
| 62 | |
| 63 | /** |
| 64 | * Either file is encrypted. |
| 65 | */ |
| 66 | public function isEncrypted(): bool |
| 67 | { |
| 68 | return false; |
| 69 | } |
| 70 | |
| 71 | /** |
| 72 | * Return the current file path. |
| 73 | */ |
| 74 | public function getPath(): string |
| 75 | { |
| 76 | return $this->path; |
| 77 | } |
| 78 | |
| 79 | /** |
| 80 | * Magic to use in string context. |
| 81 | */ |
| 82 | public function __toString(): string |
| 83 | { |
| 84 | return $this->path; |
| 85 | } |
| 86 | } |