Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ public function __construct(array $urlParams = []) {
parent::__construct('survey_client', $urlParams);
}

#[\Override]
public function register(IRegistrationContext $context): void {
}

#[\Override]
public function boot(IBootContext $context): void {
$notificationManager = $context->getServerContainer()->getNotificationManager();
$notificationManager->registerNotifierService(Notifier::class);
Expand Down
1 change: 1 addition & 0 deletions lib/BackgroundJobs/AdminNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public function __construct(
parent::__construct($time);
}

#[\Override]
protected function run($argument): void {
$notification = $this->manager->createNotification();

Expand Down
1 change: 1 addition & 0 deletions lib/BackgroundJobs/MonthlyReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public function __construct(
$this->setTimeSensitivity(IJob::TIME_SENSITIVE);
}

#[\Override]
protected function run($argument) {
if ($this->appConfig->getAppValueBool('never_again')) {
$this->jobList->remove(self::class);
Expand Down
37 changes: 14 additions & 23 deletions lib/Categories/Apps.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
Expand All @@ -17,39 +20,27 @@
* @package OCA\Survey_Client\Categories
*/
class Apps implements ICategory {
/** @var IDBConnection */
protected $connection;

/** @var \OCP\IL10N */
protected $l;

/**
* @param IDBConnection $connection
* @param IL10N $l
*/
public function __construct(IDBConnection $connection, IL10N $l) {
$this->connection = $connection;
$this->l = $l;
public function __construct(
protected IDBConnection $connection,
protected IL10N $l,
) {
}

/**
* @return string
*/
public function getCategory() {
#[\Override]
public function getCategory(): string {
return 'apps';
}

/**
* @return string
*/
public function getDisplayName() {
#[\Override]
public function getDisplayName(): string {
return $this->l->t('App list <em>(for each app: name, version, enabled status)</em>');
}

/**
* @return array (string => string|int)
* @return array<string, string|int>
*/
public function getData() {
#[\Override]
public function getData(): array {
$query = $this->connection->getQueryBuilder();

$query->select('*')
Expand Down
42 changes: 17 additions & 25 deletions lib/Categories/Database.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
Expand All @@ -17,47 +20,36 @@
* @package OCA\Survey_Client\Categories
*/
class Database implements ICategory {
/** @var IConfig */
protected $config;

/** @var IDBConnection */
protected $connection;

/** @var IL10N */
protected $l;

public function __construct(IConfig $config, IDBConnection $connection, IL10N $l) {
$this->config = $config;
$this->connection = $connection;
$this->l = $l;
public function __construct(
protected IConfig $config,
protected IDBConnection $connection,
protected IL10N $l,
) {
}

/**
* @return string
*/
public function getCategory() {
#[\Override]
public function getCategory(): string {
return 'database';
}

/**
* @return string
*/
public function getDisplayName() {
#[\Override]
public function getDisplayName(): string {
return $this->l->t('Database environment <em>(type, version, database size)</em>');
}

/**
* @return array (string => string|int)
* @return array<string, string|int>
*/
public function getData() {
#[\Override]
public function getData(): array {
return [
'type' => $this->config->getSystemValue('dbtype'),
'version' => $this->databaseVersion(),
'size' => $this->databaseSize(),
];
}

protected function databaseVersion() {
protected function databaseVersion(): string {
switch ($this->config->getSystemValue('dbtype')) {
case 'sqlite':
case 'sqlite3':
Expand Down Expand Up @@ -171,7 +163,7 @@ protected function databaseSize() {
* @param string $version E.g. `5.6.27-0ubuntu0.14.04.1`
* @return string `5.6.27`
*/
protected function cleanVersion($version) {
protected function cleanVersion($version): string {
$matches = [];
preg_match('/^(\d+)(\.\d+)(\.\d+)/', $version, $matches);
if (isset($matches[0])) {
Expand Down
37 changes: 14 additions & 23 deletions lib/Categories/Encryption.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
Expand All @@ -16,39 +19,27 @@
* @package OCA\Survey_Client\Categories
*/
class Encryption implements ICategory {
/** @var \OCP\IConfig */
protected $config;

/** @var \OCP\IL10N */
protected $l;

/**
* @param IConfig $config
* @param IL10N $l
*/
public function __construct(IConfig $config, IL10N $l) {
$this->config = $config;
$this->l = $l;
public function __construct(
protected IConfig $config,
protected IL10N $l,
) {
}

/**
* @return string
*/
public function getCategory() {
#[\Override]
public function getCategory(): string {
return 'encryption';
}

/**
* @return string
*/
public function getDisplayName() {
#[\Override]
public function getDisplayName(): string {
return $this->l->t('Encryption information <em>(is it enabled?, what is the default module)</em>');
}

/**
* @return array (string => string|int)
* @return array<string, string|int>
*/
public function getData() {
#[\Override]
public function getData(): array {
$data = [
'enabled' => $this->config->getAppValue('core', 'encryption_enabled', 'no') === 'yes' ? 'yes' : 'no',
'default_module' => $this->config->getAppValue('core', 'default_encryption_module') === 'OC_DEFAULT_MODULE' ? 'yes' : 'no',
Expand Down
50 changes: 16 additions & 34 deletions lib/Categories/FilesSharing.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
Expand All @@ -16,39 +19,27 @@
* @package OCA\Survey_Client\Categories
*/
class FilesSharing implements ICategory {
/** @var IDBConnection */
protected $connection;

/** @var \OCP\IL10N */
protected $l;

/**
* @param IDBConnection $connection
* @param IL10N $l
*/
public function __construct(IDBConnection $connection, IL10N $l) {
$this->connection = $connection;
$this->l = $l;
public function __construct(
protected IDBConnection $connection,
protected IL10N $l,
) {
}

/**
* @return string
*/
public function getCategory() {
#[\Override]
public function getCategory(): string {
return 'files_sharing';
}

/**
* @return string
*/
public function getDisplayName() {
#[\Override]
public function getDisplayName(): string {
return $this->l->t('Number of shares <em>(per type and permission setting)</em>');
}

/**
* @return array (string => string|int)
* @return array<string, string|int>
*/
public function getData() {
#[\Override]
public function getData(): array {
$query = $this->connection->getQueryBuilder();
$query->select($query->func()->count('*', 'num_entries'))
->addSelect(['permissions', 'share_type'])
Expand All @@ -74,11 +65,7 @@ public function getData() {
return $data;
}

/**
* @param string $tableName
* @return int
*/
protected function countEntries($tableName) {
protected function countEntries(string $tableName): int {
$query = $this->connection->getQueryBuilder();
$query->select($query->func()->count('*', 'num_entries'))
->from($tableName);
Expand All @@ -89,12 +76,7 @@ protected function countEntries($tableName) {
return (int)$row['num_entries'];
}

/**
* @param int $type
* @param bool $noShareWith
* @return int
*/
protected function countShares($type, $noShareWith = false) {
protected function countShares(int $type, bool $noShareWith = false): int {
$query = $this->connection->getQueryBuilder();
$query->select($query->func()->count('*', 'num_entries'))
->from('share')
Expand Down
17 changes: 7 additions & 10 deletions lib/Categories/ICategory.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
Expand All @@ -15,18 +18,12 @@
* @package OCA\Survey_Client\Categories
*/
interface ICategory {
/**
* @return string
*/
public function getCategory();
public function getCategory(): string;

/**
* @return string
*/
public function getDisplayName();
public function getDisplayName(): string;

/**
* @return array (string => string|int)
* @return array<string, string|int>
*/
public function getData();
public function getData(): array;
}
Loading
Loading