Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
33.33% |
5 / 15 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
| TSimpleFile | |
33.33% |
5 / 15 |
|
50.00% |
1 / 2 |
8.74 | |
0.00% |
0 / 1 |
| getInternalPathOfFile | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
12 | |||
| getInternalPathOfFolder | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | /** |
| 5 | * SPDX-FileCopyrightText: 2025 LibreCode coop and contributors |
| 6 | * SPDX-License-Identifier: AGPL-3.0-or-later |
| 7 | */ |
| 8 | |
| 9 | namespace OCA\Libresign\Files; |
| 10 | |
| 11 | use OCP\Files\SimpleFS\ISimpleFile; |
| 12 | use OCP\Files\SimpleFS\ISimpleFolder; |
| 13 | |
| 14 | trait TSimpleFile { |
| 15 | /** |
| 16 | * @todo check a best solution to don't use reflection |
| 17 | */ |
| 18 | public function getInternalPathOfFile(ISimpleFile $node): string { |
| 19 | $reflection = new \ReflectionClass($node); |
| 20 | if ($reflection->hasProperty('parentFolder')) { |
| 21 | $reflectionProperty = $reflection->getProperty('parentFolder'); |
| 22 | $folder = $reflectionProperty->getValue($node); |
| 23 | $path = $folder->getInternalPath() . '/' . $node->getName(); |
| 24 | } elseif ($reflection->hasProperty('file')) { |
| 25 | $reflectionProperty = $reflection->getProperty('file'); |
| 26 | $file = $reflectionProperty->getValue($node); |
| 27 | $path = $file->getPath(); |
| 28 | } |
| 29 | return $path; |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * @todo check a best solution to don't use reflection |
| 34 | */ |
| 35 | private function getInternalPathOfFolder(ISimpleFolder $node): string { |
| 36 | $reflection = new \ReflectionClass($node); |
| 37 | $reflectionProperty = $reflection->getProperty('folder'); |
| 38 | $folder = $reflectionProperty->getValue($node); |
| 39 | $path = $folder->getInternalPath(); |
| 40 | return $path; |
| 41 | } |
| 42 | } |