From f031591753c488517502cdf1d3624174fa7eaf27 Mon Sep 17 00:00:00 2001 From: Jonathan Treffler Date: Wed, 2 Jul 2025 14:46:05 +0200 Subject: [PATCH] fixed more indentations --- lib/Controller/AdminSettingsController.php | 44 +++++++-------- lib/Db/DiffTask.php | 32 +++++------ lib/Db/DiffTaskMapper.php | 36 ++++++------ lib/Db/DiffTaskResult.php | 66 +++++++++++----------- lib/Db/DiffTaskResultMapper.php | 34 +++++------ lib/Entity/Snapshot.php | 6 +- lib/Helpers/FileHelper.php | 46 +++++++-------- lib/Service/SettingsService.php | 4 +- lib/Settings/SnapshotsAdmin.php | 28 ++++----- 9 files changed, 148 insertions(+), 148 deletions(-) diff --git a/lib/Controller/AdminSettingsController.php b/lib/Controller/AdminSettingsController.php index 97302d0..399e08e 100644 --- a/lib/Controller/AdminSettingsController.php +++ b/lib/Controller/AdminSettingsController.php @@ -19,29 +19,29 @@ class AdminSettingsController extends Controller { ); } - /** - * @return JSONResponse - */ - public function index(): JSONResponse { - return new JSONResponse($this->settingsService->getAppValues()); - } + /** + * @return JSONResponse + */ + public function index(): JSONResponse { + return new JSONResponse($this->settingsService->getAppValues()); + } - /** - * @param $key - * - * @return JSONResponse - */ - public function show($key): JSONResponse { - return new JSONResponse($this->settingsService->getAppValue($key)); - } + /** + * @param $key + * + * @return JSONResponse + */ + public function show($key): JSONResponse { + return new JSONResponse($this->settingsService->getAppValue($key)); + } - /** - * @param $key - * @param $value - * - * @return JSONResponse - */ - public function update($key, $value): JSONResponse { + /** + * @param $key + * @param $value + * + * @return JSONResponse + */ + public function update($key, $value): JSONResponse { return new JSONResponse($this->settingsService->setAppValue($key, $value)); - } + } } \ No newline at end of file diff --git a/lib/Db/DiffTask.php b/lib/Db/DiffTask.php index 0398287..7a5a8c4 100644 --- a/lib/Db/DiffTask.php +++ b/lib/Db/DiffTask.php @@ -7,25 +7,25 @@ use OCP\AppFramework\Db\Entity; class DiffTask extends Entity implements JsonSerializable { - protected $userId; - protected $groupfolderId; + protected $userId; + protected $groupfolderId; protected $relativePath; - protected $snapshotId; - protected $timestamp; + protected $snapshotId; + protected $timestamp; - public function __construct() { - $this->addType('id','integer'); - $this->addType('groupfolderId','integer'); - } + public function __construct() { + $this->addType('id','integer'); + $this->addType('groupfolderId','integer'); + } - public function jsonSerialize() { - return [ - 'id' => $this->id, + public function jsonSerialize() { + return [ + 'id' => $this->id, 'userId' => $this->userId, - 'groupfolderId' => $this->groupfolderId, + 'groupfolderId' => $this->groupfolderId, 'relativePath' => $this->relativePath, - 'snapshotId' => $this->snapshotId, - 'timestamp' => $this->timestamp, - ]; - } + 'snapshotId' => $this->snapshotId, + 'timestamp' => $this->timestamp, + ]; + } } \ No newline at end of file diff --git a/lib/Db/DiffTaskMapper.php b/lib/Db/DiffTaskMapper.php index b1811c6..86f0353 100644 --- a/lib/Db/DiffTaskMapper.php +++ b/lib/Db/DiffTaskMapper.php @@ -9,29 +9,29 @@ use OCP\AppFramework\Db\QBMapper; */ class DiffTaskMapper extends QBMapper { - public function __construct(IDBConnection $db) { - parent::__construct($db, 'groupfolder_snapshots_tasks', DiffTask::class); - } + public function __construct(IDBConnection $db) { + parent::__construct($db, 'groupfolder_snapshots_tasks', DiffTask::class); + } - public function find(int $id, string $userId) { - $qb = $this->db->getQueryBuilder(); + public function find(int $id, string $userId) { + $qb = $this->db->getQueryBuilder(); - $qb->select('*') - ->from($this->getTableName()) - ->where($qb->expr()->eq('id', $qb->createNamedParameter($id))) - ->andWhere($qb->expr()->eq('user_id', $qb->createNamedParameter($userId))); + $qb->select('*') + ->from($this->getTableName()) + ->where($qb->expr()->eq('id', $qb->createNamedParameter($id))) + ->andWhere($qb->expr()->eq('user_id', $qb->createNamedParameter($userId))); - return $this->findEntity($qb); - } + return $this->findEntity($qb); + } - public function findAll(string $userId) { - $qb = $this->db->getQueryBuilder(); + public function findAll(string $userId) { + $qb = $this->db->getQueryBuilder(); - $qb->select('*') - ->from($this->getTableName()) - ->where($qb->expr()->eq('user_id', $qb->createNamedParameter($userId))); + $qb->select('*') + ->from($this->getTableName()) + ->where($qb->expr()->eq('user_id', $qb->createNamedParameter($userId))); - return $this->findEntities($qb); - } + return $this->findEntities($qb); + } } \ No newline at end of file diff --git a/lib/Db/DiffTaskResult.php b/lib/Db/DiffTaskResult.php index 7ea190a..e16d63e 100644 --- a/lib/Db/DiffTaskResult.php +++ b/lib/Db/DiffTaskResult.php @@ -7,49 +7,49 @@ use OCP\AppFramework\Db\Entity; class DiffTaskResult extends Entity implements JsonSerializable { - protected $taskId; - protected $timestamp; - protected $type; + protected $taskId; + protected $timestamp; + protected $type; - protected $beforeFileExists; - protected $beforePath; - protected $beforeSize; + protected $beforeFileExists; + protected $beforePath; + protected $beforeSize; - protected $currentFileExists; - protected $currentFileId; + protected $currentFileExists; + protected $currentFileId; protected $currentPath; - protected $currentSize; + protected $currentSize; protected $reverted; - public function __construct() { - $this->addType('id','integer'); - $this->addType('taskId','integer'); - $this->addType('beforeFileExists','boolean'); - $this->addType('beforeSize','integer'); - $this->addType('currentFileExists','boolean'); + public function __construct() { + $this->addType('id','integer'); + $this->addType('taskId','integer'); + $this->addType('beforeFileExists','boolean'); + $this->addType('beforeSize','integer'); + $this->addType('currentFileExists','boolean'); $this->addType('currentFileId','integer'); - $this->addType('currentSize','integer'); + $this->addType('currentSize','integer'); $this->addType('reverted','boolean'); - } + } - public function jsonSerialize() { - return [ - 'id' => $this->id, - 'taskId' => $this->taskId, - 'type' => $this->type, - 'before' => [ - 'fileExists' => $this->beforeFileExists, - 'path' => $this->beforePath, - 'size' => $this->beforeSize, - ], - 'current' => [ - 'fileExists' => $this->currentFileExists, + public function jsonSerialize() { + return [ + 'id' => $this->id, + 'taskId' => $this->taskId, + 'type' => $this->type, + 'before' => [ + 'fileExists' => $this->beforeFileExists, + 'path' => $this->beforePath, + 'size' => $this->beforeSize, + ], + 'current' => [ + 'fileExists' => $this->currentFileExists, 'fileId' => $this->currentFileId, - 'path' => $this->currentPath, - 'size' => $this->currentSize, + 'path' => $this->currentPath, + 'size' => $this->currentSize, ], 'reverted' => $this->reverted, - ]; - } + ]; + } } \ No newline at end of file diff --git a/lib/Db/DiffTaskResultMapper.php b/lib/Db/DiffTaskResultMapper.php index 882a0e1..7ecbaf2 100644 --- a/lib/Db/DiffTaskResultMapper.php +++ b/lib/Db/DiffTaskResultMapper.php @@ -9,29 +9,29 @@ use OCP\AppFramework\Db\QBMapper; */ class DiffTaskResultMapper extends QBMapper { - public function __construct(IDBConnection $db) { - parent::__construct($db, 'groupfolder_snapshots_task_results', DiffTaskResult::class); - } + public function __construct(IDBConnection $db) { + parent::__construct($db, 'groupfolder_snapshots_task_results', DiffTaskResult::class); + } - public function find(int $id) { - $qb = $this->db->getQueryBuilder(); + public function find(int $id) { + $qb = $this->db->getQueryBuilder(); - $qb->select('*') - ->from($this->getTableName()) - ->where($qb->expr()->eq('id', $qb->createNamedParameter($id))); + $qb->select('*') + ->from($this->getTableName()) + ->where($qb->expr()->eq('id', $qb->createNamedParameter($id))); - return $this->findEntity($qb); - } + return $this->findEntity($qb); + } - public function findAll(int $taskId) { - $qb = $this->db->getQueryBuilder(); + public function findAll(int $taskId) { + $qb = $this->db->getQueryBuilder(); - $qb->select('*') - ->from($this->getTableName()) - ->where($qb->expr()->eq('task_id', $qb->createNamedParameter($taskId))); + $qb->select('*') + ->from($this->getTableName()) + ->where($qb->expr()->eq('task_id', $qb->createNamedParameter($taskId))); - return $this->findEntities($qb); - } + return $this->findEntities($qb); + } public function markReverted(int $id) { $taskResult = $this->find($id); diff --git a/lib/Entity/Snapshot.php b/lib/Entity/Snapshot.php index d07be15..90a99fe 100644 --- a/lib/Entity/Snapshot.php +++ b/lib/Entity/Snapshot.php @@ -5,12 +5,12 @@ namespace OCA\GroupfolderFilesystemSnapshots\Entity; use JsonSerializable; class Snapshot implements JsonSerializable { - public function __construct( + public function __construct( private string $id, private string $name, private ?\DateTimeImmutable $createdTimestamp = null, ) { - } + } public function getId(): string { return $this->id; @@ -24,7 +24,7 @@ class Snapshot implements JsonSerializable { return $this->createdTimestamp; } - public function jsonSerialize(): mixed { + public function jsonSerialize(): mixed { return [ 'id' => $this->id, 'name' => $this->name, diff --git a/lib/Helpers/FileHelper.php b/lib/Helpers/FileHelper.php index c987549..27b6992 100644 --- a/lib/Helpers/FileHelper.php +++ b/lib/Helpers/FileHelper.php @@ -3,34 +3,34 @@ namespace OCA\GroupfolderFilesystemSnapshots\Helpers; class FileHelper { - private static function seperateFilesFromFolders($parentDir, $items) { - $files = []; - $folders = []; + private static function seperateFilesFromFolders($parentDir, $items) { + $files = []; + $folders = []; - foreach($items as $item) { - if(is_dir($parentDir . DIRECTORY_SEPARATOR . $item)) { - $folders[] = $item; - } else { - $files[] = $item; - } - } + foreach($items as $item) { + if(is_dir($parentDir . DIRECTORY_SEPARATOR . $item)) { + $folders[] = $item; + } else { + $files[] = $item; + } + } - return array($files, $folders); - } + return array($files, $folders); + } - public static function getFilesAndFolders($dir) { - $scan = array_diff(scandir($dir), array('..', '.')); + public static function getFilesAndFolders($dir) { + $scan = array_diff(scandir($dir), array('..', '.')); - return self::seperateFilesFromFolders($dir, $scan); - } + return self::seperateFilesFromFolders($dir, $scan); + } - public static function getFilesizesOfFiles($prefix, array $files) { - $result = array(); + public static function getFilesizesOfFiles($prefix, array $files) { + $result = array(); - foreach($files as $index=>$file) { - $result[$index] = filesize($prefix . DIRECTORY_SEPARATOR . $file); - } + foreach($files as $index=>$file) { + $result[$index] = filesize($prefix . DIRECTORY_SEPARATOR . $file); + } - return $result; - } + return $result; + } } \ No newline at end of file diff --git a/lib/Service/SettingsService.php b/lib/Service/SettingsService.php index 6c4bff0..9846e84 100644 --- a/lib/Service/SettingsService.php +++ b/lib/Service/SettingsService.php @@ -28,7 +28,7 @@ class SettingsService { } } - public function setAppValue(string $key, string $value): string { + public function setAppValue(string $key, string $value): string { if(in_array($key, self::$VALID_APP_SETTINGS)) { if($value !== '') { $this->config->setAppValue(Application::APP_ID, $key, $value); @@ -38,5 +38,5 @@ class SettingsService { return $value; } - } + } } \ No newline at end of file diff --git a/lib/Settings/SnapshotsAdmin.php b/lib/Settings/SnapshotsAdmin.php index 24bed92..848cb58 100644 --- a/lib/Settings/SnapshotsAdmin.php +++ b/lib/Settings/SnapshotsAdmin.php @@ -6,21 +6,21 @@ use OCP\Settings\ISettings; class SnapshotsAdmin implements ISettings { - public function __construct() { - } + public function __construct() { + } - /** - * @return TemplateResponse - */ - public function getForm() { - return new TemplateResponse('groupfolder_filesystem_snapshots', 'settings/admin'); - } + /** + * @return TemplateResponse + */ + public function getForm() { + return new TemplateResponse('groupfolder_filesystem_snapshots', 'settings/admin'); + } - public function getSection() { - return 'groupfolder_filesystem_snapshots'; - } + public function getSection() { + return 'groupfolder_filesystem_snapshots'; + } - public function getPriority() { - return 10; - } + public function getPriority() { + return 10; + } } \ No newline at end of file