Passed
Push — master ( a1ed1d...263a69 )
by John
16:05 queued 13s
created
apps/dav/lib/CalDAV/Reminder/NotificationTypeDoesNotExistException.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -26,15 +26,15 @@
 block discarded – undo
26 26
 
27 27
 class NotificationTypeDoesNotExistException extends \Exception {
28 28
 
29
-	/**
30
-	 * NotificationTypeDoesNotExistException constructor.
31
-	 *
32
-	 * @since 16.0.0
33
-	 *
34
-	 * @param string $type ReminderType
35
-	 */
36
-	public function __construct(string $type) {
37
-		parent::__construct("Type $type is not an accepted type of notification");
38
-	}
29
+    /**
30
+     * NotificationTypeDoesNotExistException constructor.
31
+     *
32
+     * @since 16.0.0
33
+     *
34
+     * @param string $type ReminderType
35
+     */
36
+    public function __construct(string $type) {
37
+        parent::__construct("Type $type is not an accepted type of notification");
38
+    }
39 39
 
40 40
 }
Please login to merge, or discard this patch.
lib/CalDAV/Reminder/NotificationProvider/ProviderNotAvailableException.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -25,15 +25,15 @@
 block discarded – undo
25 25
 
26 26
 class ProviderNotAvailableException extends \Exception {
27 27
 
28
-	/**
29
-	 * ProviderNotAvailableException constructor.
30
-	 *
31
-	 * @since 16.0.0
32
-	 *
33
-	 * @param string $type ReminderType
34
-	 */
35
-	public function __construct(string $type) {
36
-		parent::__construct("No notification provider for type $type available");
37
-	}
28
+    /**
29
+     * ProviderNotAvailableException constructor.
30
+     *
31
+     * @since 16.0.0
32
+     *
33
+     * @param string $type ReminderType
34
+     */
35
+    public function __construct(string $type) {
36
+        parent::__construct("No notification provider for type $type available");
37
+    }
38 38
 
39 39
 }
Please login to merge, or discard this patch.
apps/dav/lib/CalDAV/Reminder/NotificationProvider/AudioProvider.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -32,6 +32,6 @@
 block discarded – undo
32 32
  */
33 33
 class AudioProvider extends PushProvider {
34 34
 
35
-	/** @var string */
36
-	public const NOTIFICATION_TYPE = 'AUDIO';
35
+    /** @var string */
36
+    public const NOTIFICATION_TYPE = 'AUDIO';
37 37
 }
Please login to merge, or discard this patch.
lib/private/Preview/ProviderV1Adapter.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -36,11 +36,11 @@
 block discarded – undo
36 36
 	}
37 37
 
38 38
 	public function getMimeType(): string {
39
-		return (string)$this->providerV1->getMimeType();
39
+		return (string) $this->providerV1->getMimeType();
40 40
 	}
41 41
 
42 42
 	public function isAvailable(FileInfo $file): bool {
43
-		return (bool)$this->providerV1->isAvailable($file);
43
+		return (bool) $this->providerV1->isAvailable($file);
44 44
 	}
45 45
 
46 46
 	public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage {
Please login to merge, or discard this patch.
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -34,30 +34,30 @@
 block discarded – undo
34 34
 use OCP\Preview\IProviderV2;
35 35
 
36 36
 class ProviderV1Adapter implements IProviderV2 {
37
-	private $providerV1;
37
+    private $providerV1;
38 38
 
39
-	public function __construct(IProvider $providerV1) {
40
-		$this->providerV1 = $providerV1;
41
-	}
39
+    public function __construct(IProvider $providerV1) {
40
+        $this->providerV1 = $providerV1;
41
+    }
42 42
 
43
-	public function getMimeType(): string {
44
-		return (string)$this->providerV1->getMimeType();
45
-	}
43
+    public function getMimeType(): string {
44
+        return (string)$this->providerV1->getMimeType();
45
+    }
46 46
 
47
-	public function isAvailable(FileInfo $file): bool {
48
-		return (bool)$this->providerV1->isAvailable($file);
49
-	}
47
+    public function isAvailable(FileInfo $file): bool {
48
+        return (bool)$this->providerV1->isAvailable($file);
49
+    }
50 50
 
51
-	public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage {
52
-		[$view, $path] = $this->getViewAndPath($file);
53
-		$thumbnail = $this->providerV1->getThumbnail($path, $maxX, $maxY, false, $view);
54
-		return $thumbnail === false ? null: $thumbnail;
55
-	}
51
+    public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage {
52
+        [$view, $path] = $this->getViewAndPath($file);
53
+        $thumbnail = $this->providerV1->getThumbnail($path, $maxX, $maxY, false, $view);
54
+        return $thumbnail === false ? null: $thumbnail;
55
+    }
56 56
 
57
-	private function getViewAndPath(File $file) {
58
-		$view = new View(dirname($file->getPath()));
59
-		$path = $file->getName();
57
+    private function getViewAndPath(File $file) {
58
+        $view = new View(dirname($file->getPath()));
59
+        $path = $file->getName();
60 60
 
61
-		return [$view, $path];
62
-	}
61
+        return [$view, $path];
62
+    }
63 63
 }
Please login to merge, or discard this patch.
lib/private/Security/RateLimiting/Limiter.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 										string $ip): void {
81 81
 		$ipSubnet = (new IpAddress($ip))->getSubnet();
82 82
 
83
-		$anonHashIdentifier = hash('sha512', 'anon::' . $identifier . $ipSubnet);
83
+		$anonHashIdentifier = hash('sha512', 'anon::'.$identifier.$ipSubnet);
84 84
 		$this->register($identifier, $anonHashIdentifier, $anonPeriod, $anonLimit);
85 85
 	}
86 86
 
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 										int $userLimit,
98 98
 										int $userPeriod,
99 99
 										IUser $user): void {
100
-		$userHashIdentifier = hash('sha512', 'user::' . $identifier . $user->getUID());
100
+		$userHashIdentifier = hash('sha512', 'user::'.$identifier.$user->getUID());
101 101
 		$this->register($identifier, $userHashIdentifier, $userPeriod, $userLimit);
102 102
 	}
103 103
 }
Please login to merge, or discard this patch.
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -32,68 +32,68 @@
 block discarded – undo
32 32
 use OCP\IUser;
33 33
 
34 34
 class Limiter {
35
-	/** @var IBackend */
36
-	private $backend;
35
+    /** @var IBackend */
36
+    private $backend;
37 37
 
38
-	/**
39
-	 * @param IBackend $backend
40
-	 */
41
-	public function __construct(IBackend $backend) {
42
-		$this->backend = $backend;
43
-	}
38
+    /**
39
+     * @param IBackend $backend
40
+     */
41
+    public function __construct(IBackend $backend) {
42
+        $this->backend = $backend;
43
+    }
44 44
 
45
-	/**
46
-	 * @param string $methodIdentifier
47
-	 * @param string $userIdentifier
48
-	 * @param int $period in seconds
49
-	 * @param int $limit
50
-	 * @throws RateLimitExceededException
51
-	 */
52
-	private function register(string $methodIdentifier,
53
-							  string $userIdentifier,
54
-							  int $period,
55
-							  int $limit): void {
56
-		$existingAttempts = $this->backend->getAttempts($methodIdentifier, $userIdentifier);
57
-		if ($existingAttempts >= $limit) {
58
-			throw new RateLimitExceededException();
59
-		}
45
+    /**
46
+     * @param string $methodIdentifier
47
+     * @param string $userIdentifier
48
+     * @param int $period in seconds
49
+     * @param int $limit
50
+     * @throws RateLimitExceededException
51
+     */
52
+    private function register(string $methodIdentifier,
53
+                                string $userIdentifier,
54
+                                int $period,
55
+                                int $limit): void {
56
+        $existingAttempts = $this->backend->getAttempts($methodIdentifier, $userIdentifier);
57
+        if ($existingAttempts >= $limit) {
58
+            throw new RateLimitExceededException();
59
+        }
60 60
 
61
-		$this->backend->registerAttempt($methodIdentifier, $userIdentifier, $period);
62
-	}
61
+        $this->backend->registerAttempt($methodIdentifier, $userIdentifier, $period);
62
+    }
63 63
 
64
-	/**
65
-	 * Registers attempt for an anonymous request
66
-	 *
67
-	 * @param string $identifier
68
-	 * @param int $anonLimit
69
-	 * @param int $anonPeriod in seconds
70
-	 * @param string $ip
71
-	 * @throws RateLimitExceededException
72
-	 */
73
-	public function registerAnonRequest(string $identifier,
74
-										int $anonLimit,
75
-										int $anonPeriod,
76
-										string $ip): void {
77
-		$ipSubnet = (new IpAddress($ip))->getSubnet();
64
+    /**
65
+     * Registers attempt for an anonymous request
66
+     *
67
+     * @param string $identifier
68
+     * @param int $anonLimit
69
+     * @param int $anonPeriod in seconds
70
+     * @param string $ip
71
+     * @throws RateLimitExceededException
72
+     */
73
+    public function registerAnonRequest(string $identifier,
74
+                                        int $anonLimit,
75
+                                        int $anonPeriod,
76
+                                        string $ip): void {
77
+        $ipSubnet = (new IpAddress($ip))->getSubnet();
78 78
 
79
-		$anonHashIdentifier = hash('sha512', 'anon::' . $identifier . $ipSubnet);
80
-		$this->register($identifier, $anonHashIdentifier, $anonPeriod, $anonLimit);
81
-	}
79
+        $anonHashIdentifier = hash('sha512', 'anon::' . $identifier . $ipSubnet);
80
+        $this->register($identifier, $anonHashIdentifier, $anonPeriod, $anonLimit);
81
+    }
82 82
 
83
-	/**
84
-	 * Registers attempt for an authenticated request
85
-	 *
86
-	 * @param string $identifier
87
-	 * @param int $userLimit
88
-	 * @param int $userPeriod in seconds
89
-	 * @param IUser $user
90
-	 * @throws RateLimitExceededException
91
-	 */
92
-	public function registerUserRequest(string $identifier,
93
-										int $userLimit,
94
-										int $userPeriod,
95
-										IUser $user): void {
96
-		$userHashIdentifier = hash('sha512', 'user::' . $identifier . $user->getUID());
97
-		$this->register($identifier, $userHashIdentifier, $userPeriod, $userLimit);
98
-	}
83
+    /**
84
+     * Registers attempt for an authenticated request
85
+     *
86
+     * @param string $identifier
87
+     * @param int $userLimit
88
+     * @param int $userPeriod in seconds
89
+     * @param IUser $user
90
+     * @throws RateLimitExceededException
91
+     */
92
+    public function registerUserRequest(string $identifier,
93
+                                        int $userLimit,
94
+                                        int $userPeriod,
95
+                                        IUser $user): void {
96
+        $userHashIdentifier = hash('sha512', 'user::' . $identifier . $user->getUID());
97
+        $this->register($identifier, $userHashIdentifier, $userPeriod, $userLimit);
98
+    }
99 99
 }
Please login to merge, or discard this patch.
apps/dav/lib/Migration/RemoveOrphanEventsAndContacts.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -48,23 +48,23 @@  discard block
 block discarded – undo
48 48
 	 * @inheritdoc
49 49
 	 */
50 50
 	public function run(IOutput $output) {
51
-		$orphanItems = $this->removeOrphanChildren('calendarobjects', 'calendars',  'calendarid');
51
+		$orphanItems = $this->removeOrphanChildren('calendarobjects', 'calendars', 'calendarid');
52 52
 		$output->info(sprintf('%d events without a calendar have been cleaned up', $orphanItems));
53
-		$orphanItems = $this->removeOrphanChildren('calendarobjects_props', 'calendarobjects',  'objectid');
53
+		$orphanItems = $this->removeOrphanChildren('calendarobjects_props', 'calendarobjects', 'objectid');
54 54
 		$output->info(sprintf('%d properties without an events have been cleaned up', $orphanItems));
55
-		$orphanItems = $this->removeOrphanChildren('calendarchanges', 'calendars',  'calendarid');
55
+		$orphanItems = $this->removeOrphanChildren('calendarchanges', 'calendars', 'calendarid');
56 56
 		$output->info(sprintf('%d changes without a calendar have been cleaned up', $orphanItems));
57 57
 
58
-		$orphanItems = $this->removeOrphanChildren('calendarobjects', 'calendarsubscriptions',  'calendarid');
58
+		$orphanItems = $this->removeOrphanChildren('calendarobjects', 'calendarsubscriptions', 'calendarid');
59 59
 		$output->info(sprintf('%d cached events without a calendar subscription have been cleaned up', $orphanItems));
60
-		$orphanItems = $this->removeOrphanChildren('calendarchanges', 'calendarsubscriptions',  'calendarid');
60
+		$orphanItems = $this->removeOrphanChildren('calendarchanges', 'calendarsubscriptions', 'calendarid');
61 61
 		$output->info(sprintf('%d changes without a calendar subscription have been cleaned up', $orphanItems));
62 62
 
63
-		$orphanItems = $this->removeOrphanChildren('cards', 'addressbooks',  'addressbookid');
63
+		$orphanItems = $this->removeOrphanChildren('cards', 'addressbooks', 'addressbookid');
64 64
 		$output->info(sprintf('%d contacts without an addressbook have been cleaned up', $orphanItems));
65
-		$orphanItems = $this->removeOrphanChildren('cards_properties', 'cards',  'cardid');
65
+		$orphanItems = $this->removeOrphanChildren('cards_properties', 'cards', 'cardid');
66 66
 		$output->info(sprintf('%d properties without a contact have been cleaned up', $orphanItems));
67
-		$orphanItems = $this->removeOrphanChildren('addressbookchanges', 'addressbooks',  'addressbookid');
67
+		$orphanItems = $this->removeOrphanChildren('addressbookchanges', 'addressbooks', 'addressbookid');
68 68
 		$output->info(sprintf('%d changes without an addressbook have been cleaned up', $orphanItems));
69 69
 	}
70 70
 
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 
74 74
 		$qb->select('c.id')
75 75
 			->from($childTable, 'c')
76
-			->leftJoin('c', $parentTable, 'p', $qb->expr()->eq('c.' . $parentId, 'p.id'))
76
+			->leftJoin('c', $parentTable, 'p', $qb->expr()->eq('c.'.$parentId, 'p.id'))
77 77
 			->where($qb->expr()->isNull('p.id'));
78 78
 
79 79
 		if (\in_array($parentTable, ['calendars', 'calendarsubscriptions'], true)) {
Please login to merge, or discard this patch.
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -35,76 +35,76 @@
 block discarded – undo
35 35
 
36 36
 class RemoveOrphanEventsAndContacts implements IRepairStep {
37 37
 
38
-	/** @var IDBConnection */
39
-	private $connection;
40
-
41
-	public function __construct(IDBConnection $connection) {
42
-		$this->connection = $connection;
43
-	}
44
-
45
-	/**
46
-	 * @inheritdoc
47
-	 */
48
-	public function getName(): string {
49
-		return 'Clean up orphan event and contact data';
50
-	}
51
-
52
-	/**
53
-	 * @inheritdoc
54
-	 */
55
-	public function run(IOutput $output) {
56
-		$orphanItems = $this->removeOrphanChildren('calendarobjects', 'calendars',  'calendarid');
57
-		$output->info(sprintf('%d events without a calendar have been cleaned up', $orphanItems));
58
-		$orphanItems = $this->removeOrphanChildren('calendarobjects_props', 'calendarobjects',  'objectid');
59
-		$output->info(sprintf('%d properties without an events have been cleaned up', $orphanItems));
60
-		$orphanItems = $this->removeOrphanChildren('calendarchanges', 'calendars',  'calendarid');
61
-		$output->info(sprintf('%d changes without a calendar have been cleaned up', $orphanItems));
62
-
63
-		$orphanItems = $this->removeOrphanChildren('calendarobjects', 'calendarsubscriptions',  'calendarid');
64
-		$output->info(sprintf('%d cached events without a calendar subscription have been cleaned up', $orphanItems));
65
-		$orphanItems = $this->removeOrphanChildren('calendarchanges', 'calendarsubscriptions',  'calendarid');
66
-		$output->info(sprintf('%d changes without a calendar subscription have been cleaned up', $orphanItems));
67
-
68
-		$orphanItems = $this->removeOrphanChildren('cards', 'addressbooks',  'addressbookid');
69
-		$output->info(sprintf('%d contacts without an addressbook have been cleaned up', $orphanItems));
70
-		$orphanItems = $this->removeOrphanChildren('cards_properties', 'cards',  'cardid');
71
-		$output->info(sprintf('%d properties without a contact have been cleaned up', $orphanItems));
72
-		$orphanItems = $this->removeOrphanChildren('addressbookchanges', 'addressbooks',  'addressbookid');
73
-		$output->info(sprintf('%d changes without an addressbook have been cleaned up', $orphanItems));
74
-	}
75
-
76
-	protected function removeOrphanChildren($childTable, $parentTable, $parentId): int {
77
-		$qb = $this->connection->getQueryBuilder();
78
-
79
-		$qb->select('c.id')
80
-			->from($childTable, 'c')
81
-			->leftJoin('c', $parentTable, 'p', $qb->expr()->eq('c.' . $parentId, 'p.id'))
82
-			->where($qb->expr()->isNull('p.id'));
83
-
84
-		if (\in_array($parentTable, ['calendars', 'calendarsubscriptions'], true)) {
85
-			$calendarType = $parentTable === 'calendarsubscriptions' ? CalDavBackend::CALENDAR_TYPE_SUBSCRIPTION : CalDavBackend::CALENDAR_TYPE_CALENDAR;
86
-			$qb->andWhere($qb->expr()->eq('c.calendartype', $qb->createNamedParameter($calendarType, IQueryBuilder::PARAM_INT), IQueryBuilder::PARAM_INT));
87
-		}
88
-
89
-		$result = $qb->execute();
90
-
91
-		$orphanItems = [];
92
-		while ($row = $result->fetch()) {
93
-			$orphanItems[] = (int) $row['id'];
94
-		}
95
-		$result->closeCursor();
96
-
97
-		if (!empty($orphanItems)) {
98
-			$qb->delete($childTable)
99
-				->where($qb->expr()->in('id', $qb->createParameter('ids')));
100
-
101
-			$orphanItemsBatch = array_chunk($orphanItems, 200);
102
-			foreach ($orphanItemsBatch as $items) {
103
-				$qb->setParameter('ids', $items, IQueryBuilder::PARAM_INT_ARRAY);
104
-				$qb->execute();
105
-			}
106
-		}
107
-
108
-		return count($orphanItems);
109
-	}
38
+    /** @var IDBConnection */
39
+    private $connection;
40
+
41
+    public function __construct(IDBConnection $connection) {
42
+        $this->connection = $connection;
43
+    }
44
+
45
+    /**
46
+     * @inheritdoc
47
+     */
48
+    public function getName(): string {
49
+        return 'Clean up orphan event and contact data';
50
+    }
51
+
52
+    /**
53
+     * @inheritdoc
54
+     */
55
+    public function run(IOutput $output) {
56
+        $orphanItems = $this->removeOrphanChildren('calendarobjects', 'calendars',  'calendarid');
57
+        $output->info(sprintf('%d events without a calendar have been cleaned up', $orphanItems));
58
+        $orphanItems = $this->removeOrphanChildren('calendarobjects_props', 'calendarobjects',  'objectid');
59
+        $output->info(sprintf('%d properties without an events have been cleaned up', $orphanItems));
60
+        $orphanItems = $this->removeOrphanChildren('calendarchanges', 'calendars',  'calendarid');
61
+        $output->info(sprintf('%d changes without a calendar have been cleaned up', $orphanItems));
62
+
63
+        $orphanItems = $this->removeOrphanChildren('calendarobjects', 'calendarsubscriptions',  'calendarid');
64
+        $output->info(sprintf('%d cached events without a calendar subscription have been cleaned up', $orphanItems));
65
+        $orphanItems = $this->removeOrphanChildren('calendarchanges', 'calendarsubscriptions',  'calendarid');
66
+        $output->info(sprintf('%d changes without a calendar subscription have been cleaned up', $orphanItems));
67
+
68
+        $orphanItems = $this->removeOrphanChildren('cards', 'addressbooks',  'addressbookid');
69
+        $output->info(sprintf('%d contacts without an addressbook have been cleaned up', $orphanItems));
70
+        $orphanItems = $this->removeOrphanChildren('cards_properties', 'cards',  'cardid');
71
+        $output->info(sprintf('%d properties without a contact have been cleaned up', $orphanItems));
72
+        $orphanItems = $this->removeOrphanChildren('addressbookchanges', 'addressbooks',  'addressbookid');
73
+        $output->info(sprintf('%d changes without an addressbook have been cleaned up', $orphanItems));
74
+    }
75
+
76
+    protected function removeOrphanChildren($childTable, $parentTable, $parentId): int {
77
+        $qb = $this->connection->getQueryBuilder();
78
+
79
+        $qb->select('c.id')
80
+            ->from($childTable, 'c')
81
+            ->leftJoin('c', $parentTable, 'p', $qb->expr()->eq('c.' . $parentId, 'p.id'))
82
+            ->where($qb->expr()->isNull('p.id'));
83
+
84
+        if (\in_array($parentTable, ['calendars', 'calendarsubscriptions'], true)) {
85
+            $calendarType = $parentTable === 'calendarsubscriptions' ? CalDavBackend::CALENDAR_TYPE_SUBSCRIPTION : CalDavBackend::CALENDAR_TYPE_CALENDAR;
86
+            $qb->andWhere($qb->expr()->eq('c.calendartype', $qb->createNamedParameter($calendarType, IQueryBuilder::PARAM_INT), IQueryBuilder::PARAM_INT));
87
+        }
88
+
89
+        $result = $qb->execute();
90
+
91
+        $orphanItems = [];
92
+        while ($row = $result->fetch()) {
93
+            $orphanItems[] = (int) $row['id'];
94
+        }
95
+        $result->closeCursor();
96
+
97
+        if (!empty($orphanItems)) {
98
+            $qb->delete($childTable)
99
+                ->where($qb->expr()->in('id', $qb->createParameter('ids')));
100
+
101
+            $orphanItemsBatch = array_chunk($orphanItems, 200);
102
+            foreach ($orphanItemsBatch as $items) {
103
+                $qb->setParameter('ids', $items, IQueryBuilder::PARAM_INT_ARRAY);
104
+                $qb->execute();
105
+            }
106
+        }
107
+
108
+        return count($orphanItems);
109
+    }
110 110
 }
Please login to merge, or discard this patch.
apps/workflowengine/lib/Check/FileSize.php 2 patches
Indentation   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -31,91 +31,91 @@
 block discarded – undo
31 31
 
32 32
 class FileSize implements ICheck {
33 33
 
34
-	/** @var int */
35
-	protected $size;
36
-
37
-	/** @var IL10N */
38
-	protected $l;
39
-
40
-	/** @var IRequest */
41
-	protected $request;
42
-
43
-	/**
44
-	 * @param IL10N $l
45
-	 * @param IRequest $request
46
-	 */
47
-	public function __construct(IL10N $l, IRequest $request) {
48
-		$this->l = $l;
49
-		$this->request = $request;
50
-	}
51
-
52
-	/**
53
-	 * @param string $operator
54
-	 * @param string $value
55
-	 * @return bool
56
-	 */
57
-	public function executeCheck($operator, $value) {
58
-		$size = $this->getFileSizeFromHeader();
59
-
60
-		$value = Util::computerFileSize($value);
61
-		if ($size !== false) {
62
-			switch ($operator) {
63
-				case 'less':
64
-					return $size < $value;
65
-				case '!less':
66
-					return $size >= $value;
67
-				case 'greater':
68
-					return $size > $value;
69
-				case '!greater':
70
-					return $size <= $value;
71
-			}
72
-		}
73
-		return false;
74
-	}
75
-
76
-	/**
77
-	 * @param string $operator
78
-	 * @param string $value
79
-	 * @throws \UnexpectedValueException
80
-	 */
81
-	public function validateCheck($operator, $value) {
82
-		if (!in_array($operator, ['less', '!less', 'greater', '!greater'])) {
83
-			throw new \UnexpectedValueException($this->l->t('The given operator is invalid'), 1);
84
-		}
85
-
86
-		if (!preg_match('/^[0-9]+[ ]?[kmgt]?b$/i', $value)) {
87
-			throw new \UnexpectedValueException($this->l->t('The given file size is invalid'), 2);
88
-		}
89
-	}
90
-
91
-	/**
92
-	 * @return string
93
-	 */
94
-	protected function getFileSizeFromHeader() {
95
-		if ($this->size !== null) {
96
-			return $this->size;
97
-		}
98
-
99
-		$size = $this->request->getHeader('OC-Total-Length');
100
-		if ($size === '') {
101
-			if (in_array($this->request->getMethod(), ['POST', 'PUT'])) {
102
-				$size = $this->request->getHeader('Content-Length');
103
-			}
104
-		}
105
-
106
-		if ($size === '') {
107
-			$size = false;
108
-		}
109
-
110
-		$this->size = $size;
111
-		return $this->size;
112
-	}
113
-
114
-	public function supportedEntities(): array {
115
-		return [ File::class ];
116
-	}
117
-
118
-	public function isAvailableForScope(int $scope): bool {
119
-		return true;
120
-	}
34
+    /** @var int */
35
+    protected $size;
36
+
37
+    /** @var IL10N */
38
+    protected $l;
39
+
40
+    /** @var IRequest */
41
+    protected $request;
42
+
43
+    /**
44
+     * @param IL10N $l
45
+     * @param IRequest $request
46
+     */
47
+    public function __construct(IL10N $l, IRequest $request) {
48
+        $this->l = $l;
49
+        $this->request = $request;
50
+    }
51
+
52
+    /**
53
+     * @param string $operator
54
+     * @param string $value
55
+     * @return bool
56
+     */
57
+    public function executeCheck($operator, $value) {
58
+        $size = $this->getFileSizeFromHeader();
59
+
60
+        $value = Util::computerFileSize($value);
61
+        if ($size !== false) {
62
+            switch ($operator) {
63
+                case 'less':
64
+                    return $size < $value;
65
+                case '!less':
66
+                    return $size >= $value;
67
+                case 'greater':
68
+                    return $size > $value;
69
+                case '!greater':
70
+                    return $size <= $value;
71
+            }
72
+        }
73
+        return false;
74
+    }
75
+
76
+    /**
77
+     * @param string $operator
78
+     * @param string $value
79
+     * @throws \UnexpectedValueException
80
+     */
81
+    public function validateCheck($operator, $value) {
82
+        if (!in_array($operator, ['less', '!less', 'greater', '!greater'])) {
83
+            throw new \UnexpectedValueException($this->l->t('The given operator is invalid'), 1);
84
+        }
85
+
86
+        if (!preg_match('/^[0-9]+[ ]?[kmgt]?b$/i', $value)) {
87
+            throw new \UnexpectedValueException($this->l->t('The given file size is invalid'), 2);
88
+        }
89
+    }
90
+
91
+    /**
92
+     * @return string
93
+     */
94
+    protected function getFileSizeFromHeader() {
95
+        if ($this->size !== null) {
96
+            return $this->size;
97
+        }
98
+
99
+        $size = $this->request->getHeader('OC-Total-Length');
100
+        if ($size === '') {
101
+            if (in_array($this->request->getMethod(), ['POST', 'PUT'])) {
102
+                $size = $this->request->getHeader('Content-Length');
103
+            }
104
+        }
105
+
106
+        if ($size === '') {
107
+            $size = false;
108
+        }
109
+
110
+        $this->size = $size;
111
+        return $this->size;
112
+    }
113
+
114
+    public function supportedEntities(): array {
115
+        return [ File::class ];
116
+    }
117
+
118
+    public function isAvailableForScope(int $scope): bool {
119
+        return true;
120
+    }
121 121
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -155,7 +155,7 @@
 block discarded – undo
155 155
 	}
156 156
 
157 157
 	public function supportedEntities(): array {
158
-		return [ File::class ];
158
+		return [File::class];
159 159
 	}
160 160
 
161 161
 	public function isAvailableForScope(int $scope): bool {
Please login to merge, or discard this patch.
apps/workflowengine/lib/Check/UserGroupMembership.php 1 patch
Indentation   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -31,86 +31,86 @@
 block discarded – undo
31 31
 
32 32
 class UserGroupMembership implements ICheck {
33 33
 
34
-	/** @var string */
35
-	protected $cachedUser;
36
-
37
-	/** @var string[] */
38
-	protected $cachedGroupMemberships;
39
-
40
-	/** @var IUserSession */
41
-	protected $userSession;
42
-
43
-	/** @var IGroupManager */
44
-	protected $groupManager;
45
-
46
-	/** @var IL10N */
47
-	protected $l;
48
-
49
-	/**
50
-	 * @param IUserSession $userSession
51
-	 * @param IGroupManager $groupManager
52
-	 * @param IL10N $l
53
-	 */
54
-	public function __construct(IUserSession $userSession, IGroupManager $groupManager, IL10N $l) {
55
-		$this->userSession = $userSession;
56
-		$this->groupManager = $groupManager;
57
-		$this->l = $l;
58
-	}
59
-
60
-	/**
61
-	 * @param string $operator
62
-	 * @param string $value
63
-	 * @return bool
64
-	 */
65
-	public function executeCheck($operator, $value) {
66
-		$user = $this->userSession->getUser();
67
-
68
-		if ($user instanceof IUser) {
69
-			$groupIds = $this->getUserGroups($user);
70
-			return ($operator === 'is') === in_array($value, $groupIds);
71
-		} else {
72
-			return $operator !== 'is';
73
-		}
74
-	}
75
-
76
-
77
-	/**
78
-	 * @param string $operator
79
-	 * @param string $value
80
-	 * @throws \UnexpectedValueException
81
-	 */
82
-	public function validateCheck($operator, $value) {
83
-		if (!in_array($operator, ['is', '!is'])) {
84
-			throw new \UnexpectedValueException($this->l->t('The given operator is invalid'), 1);
85
-		}
86
-
87
-		if (!$this->groupManager->groupExists($value)) {
88
-			throw new \UnexpectedValueException($this->l->t('The given group does not exist'), 2);
89
-		}
90
-	}
91
-
92
-	/**
93
-	 * @param IUser $user
94
-	 * @return string[]
95
-	 */
96
-	protected function getUserGroups(IUser $user) {
97
-		$uid = $user->getUID();
98
-
99
-		if ($this->cachedUser !== $uid) {
100
-			$this->cachedUser = $uid;
101
-			$this->cachedGroupMemberships = $this->groupManager->getUserGroupIds($user);
102
-		}
103
-
104
-		return $this->cachedGroupMemberships;
105
-	}
106
-
107
-	public function supportedEntities(): array {
108
-		// universal by default
109
-		return [];
110
-	}
111
-
112
-	public function isAvailableForScope(int $scope): bool {
113
-		// admin only by default
114
-		return $scope === IManager::SCOPE_ADMIN;
115
-	}
34
+    /** @var string */
35
+    protected $cachedUser;
36
+
37
+    /** @var string[] */
38
+    protected $cachedGroupMemberships;
39
+
40
+    /** @var IUserSession */
41
+    protected $userSession;
42
+
43
+    /** @var IGroupManager */
44
+    protected $groupManager;
45
+
46
+    /** @var IL10N */
47
+    protected $l;
48
+
49
+    /**
50
+     * @param IUserSession $userSession
51
+     * @param IGroupManager $groupManager
52
+     * @param IL10N $l
53
+     */
54
+    public function __construct(IUserSession $userSession, IGroupManager $groupManager, IL10N $l) {
55
+        $this->userSession = $userSession;
56
+        $this->groupManager = $groupManager;
57
+        $this->l = $l;
58
+    }
59
+
60
+    /**
61
+     * @param string $operator
62
+     * @param string $value
63
+     * @return bool
64
+     */
65
+    public function executeCheck($operator, $value) {
66
+        $user = $this->userSession->getUser();
67
+
68
+        if ($user instanceof IUser) {
69
+            $groupIds = $this->getUserGroups($user);
70
+            return ($operator === 'is') === in_array($value, $groupIds);
71
+        } else {
72
+            return $operator !== 'is';
73
+        }
74
+    }
75
+
76
+
77
+    /**
78
+     * @param string $operator
79
+     * @param string $value
80
+     * @throws \UnexpectedValueException
81
+     */
82
+    public function validateCheck($operator, $value) {
83
+        if (!in_array($operator, ['is', '!is'])) {
84
+            throw new \UnexpectedValueException($this->l->t('The given operator is invalid'), 1);
85
+        }
86
+
87
+        if (!$this->groupManager->groupExists($value)) {
88
+            throw new \UnexpectedValueException($this->l->t('The given group does not exist'), 2);
89
+        }
90
+    }
91
+
92
+    /**
93
+     * @param IUser $user
94
+     * @return string[]
95
+     */
96
+    protected function getUserGroups(IUser $user) {
97
+        $uid = $user->getUID();
98
+
99
+        if ($this->cachedUser !== $uid) {
100
+            $this->cachedUser = $uid;
101
+            $this->cachedGroupMemberships = $this->groupManager->getUserGroupIds($user);
102
+        }
103
+
104
+        return $this->cachedGroupMemberships;
105
+    }
106
+
107
+    public function supportedEntities(): array {
108
+        // universal by default
109
+        return [];
110
+    }
111
+
112
+    public function isAvailableForScope(int $scope): bool {
113
+        // admin only by default
114
+        return $scope === IManager::SCOPE_ADMIN;
115
+    }
116 116
 }
Please login to merge, or discard this patch.
lib/public/WorkflowEngine/IEntityCheck.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -34,21 +34,21 @@
 block discarded – undo
34 34
  * @since 18.0.0
35 35
  */
36 36
 interface IEntityCheck {
37
-	/**
38
-	 * Equips the check with a subject fitting the Entity. For instance, an
39
-	 * entity of File will receive an instance of OCP\Files\Node, or a comment
40
-	 * entity might get an IComment.
41
-	 *
42
-	 * The implementing check must be aware of the incoming type.
43
-	 *
44
-	 * If an unsupported subject is passed the implementation MAY throw an
45
-	 * \UnexpectedValueException.
46
-	 *
47
-	 * @param IEntity $entity
48
-	 * @param mixed $subject
49
-	 * @throws \UnexpectedValueException
50
-	 * @since 18.0.0
51
-	 */
52
-	public function setEntitySubject(IEntity $entity, $subject): void;
37
+    /**
38
+     * Equips the check with a subject fitting the Entity. For instance, an
39
+     * entity of File will receive an instance of OCP\Files\Node, or a comment
40
+     * entity might get an IComment.
41
+     *
42
+     * The implementing check must be aware of the incoming type.
43
+     *
44
+     * If an unsupported subject is passed the implementation MAY throw an
45
+     * \UnexpectedValueException.
46
+     *
47
+     * @param IEntity $entity
48
+     * @param mixed $subject
49
+     * @throws \UnexpectedValueException
50
+     * @since 18.0.0
51
+     */
52
+    public function setEntitySubject(IEntity $entity, $subject): void;
53 53
 
54 54
 }
Please login to merge, or discard this patch.