Passed
Push — master ( acba3d...0e2f31 )
by Roeland
35:10 queued 21:35
created
lib/private/InitialStateService.php 1 patch
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -33,70 +33,70 @@
 block discarded – undo
33 33
 
34 34
 class InitialStateService implements IInitialStateService {
35 35
 
36
-	/** @var ILogger */
37
-	private $logger;
36
+    /** @var ILogger */
37
+    private $logger;
38 38
 
39
-	/** @var string[][] */
40
-	private $states = [];
39
+    /** @var string[][] */
40
+    private $states = [];
41 41
 
42
-	/** @var Closure[][] */
43
-	private $lazyStates = [];
42
+    /** @var Closure[][] */
43
+    private $lazyStates = [];
44 44
 
45
-	public function __construct(ILogger $logger) {
46
-		$this->logger = $logger;
47
-	}
45
+    public function __construct(ILogger $logger) {
46
+        $this->logger = $logger;
47
+    }
48 48
 
49
-	public function provideInitialState(string $appName, string $key, $data): void {
50
-		// Scalars and JsonSerializable are fine
51
-		if (is_scalar($data) || $data instanceof \JsonSerializable || is_array($data)) {
52
-			if (!isset($this->states[$appName])) {
53
-				$this->states[$appName] = [];
54
-			}
55
-			$this->states[$appName][$key] = json_encode($data);
56
-			return;
57
-		}
49
+    public function provideInitialState(string $appName, string $key, $data): void {
50
+        // Scalars and JsonSerializable are fine
51
+        if (is_scalar($data) || $data instanceof \JsonSerializable || is_array($data)) {
52
+            if (!isset($this->states[$appName])) {
53
+                $this->states[$appName] = [];
54
+            }
55
+            $this->states[$appName][$key] = json_encode($data);
56
+            return;
57
+        }
58 58
 
59
-		$this->logger->warning('Invalid data provided to provideInitialState by ' . $appName);
60
-	}
59
+        $this->logger->warning('Invalid data provided to provideInitialState by ' . $appName);
60
+    }
61 61
 
62
-	public function provideLazyInitialState(string $appName, string $key, Closure $closure): void {
63
-		if (!isset($this->lazyStates[$appName])) {
64
-			$this->lazyStates[$appName] = [];
65
-		}
66
-		$this->lazyStates[$appName][$key] = $closure;
67
-	}
62
+    public function provideLazyInitialState(string $appName, string $key, Closure $closure): void {
63
+        if (!isset($this->lazyStates[$appName])) {
64
+            $this->lazyStates[$appName] = [];
65
+        }
66
+        $this->lazyStates[$appName][$key] = $closure;
67
+    }
68 68
 
69
-	/**
70
-	 * Invoke all callbacks to populate the `states` property
71
-	 */
72
-	private function invokeLazyStateCallbacks(): void {
73
-		foreach ($this->lazyStates as $app => $lazyStates) {
74
-			foreach ($lazyStates as $key => $lazyState) {
75
-				$startTime = microtime(true);
76
-				$this->provideInitialState($app, $key, $lazyState());
77
-				$endTime = microtime(true);
78
-				$duration = $endTime - $startTime;
79
-				if ($duration > 1) {
80
-					$this->logger->warning('Lazy initial state provider for {key} took {duration} seconds.', [
81
-						'app' => $app,
82
-						'key' => $key,
83
-						'duration' => round($duration, 2),
84
-					]);
85
-				}
86
-			}
87
-		}
88
-		$this->lazyStates = [];
89
-	}
69
+    /**
70
+     * Invoke all callbacks to populate the `states` property
71
+     */
72
+    private function invokeLazyStateCallbacks(): void {
73
+        foreach ($this->lazyStates as $app => $lazyStates) {
74
+            foreach ($lazyStates as $key => $lazyState) {
75
+                $startTime = microtime(true);
76
+                $this->provideInitialState($app, $key, $lazyState());
77
+                $endTime = microtime(true);
78
+                $duration = $endTime - $startTime;
79
+                if ($duration > 1) {
80
+                    $this->logger->warning('Lazy initial state provider for {key} took {duration} seconds.', [
81
+                        'app' => $app,
82
+                        'key' => $key,
83
+                        'duration' => round($duration, 2),
84
+                    ]);
85
+                }
86
+            }
87
+        }
88
+        $this->lazyStates = [];
89
+    }
90 90
 
91
-	public function getInitialStates(): array {
92
-		$this->invokeLazyStateCallbacks();
91
+    public function getInitialStates(): array {
92
+        $this->invokeLazyStateCallbacks();
93 93
 
94
-		$appStates = [];
95
-		foreach ($this->states as $app => $states) {
96
-			foreach ($states as $key => $value) {
97
-				$appStates["$app-$key"] = $value;
98
-			}
99
-		}
100
-		return $appStates;
101
-	}
94
+        $appStates = [];
95
+        foreach ($this->states as $app => $states) {
96
+            foreach ($states as $key => $value) {
97
+                $appStates["$app-$key"] = $value;
98
+            }
99
+        }
100
+        return $appStates;
101
+    }
102 102
 }
Please login to merge, or discard this patch.
lib/private/Dashboard/Manager.php 2 patches
Indentation   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -36,87 +36,87 @@
 block discarded – undo
36 36
 
37 37
 class Manager implements IManager {
38 38
 
39
-	/** @var array */
40
-	private $lazyWidgets = [];
39
+    /** @var array */
40
+    private $lazyWidgets = [];
41 41
 
42
-	/** @var IWidget[] */
43
-	private $widgets = [];
42
+    /** @var IWidget[] */
43
+    private $widgets = [];
44 44
 
45
-	/** @var IServerContainer */
46
-	private $serverContainer;
45
+    /** @var IServerContainer */
46
+    private $serverContainer;
47 47
 
48
-	public function __construct(IServerContainer $serverContainer) {
49
-		$this->serverContainer = $serverContainer;
50
-	}
48
+    public function __construct(IServerContainer $serverContainer) {
49
+        $this->serverContainer = $serverContainer;
50
+    }
51 51
 
52
-	private function registerWidget(IWidget $widget): void {
53
-		if (array_key_exists($widget->getId(), $this->widgets)) {
54
-			throw new InvalidArgumentException('Dashboard widget with this id has already been registered');
55
-		}
52
+    private function registerWidget(IWidget $widget): void {
53
+        if (array_key_exists($widget->getId(), $this->widgets)) {
54
+            throw new InvalidArgumentException('Dashboard widget with this id has already been registered');
55
+        }
56 56
 
57
-		$this->widgets[$widget->getId()] = $widget;
58
-	}
57
+        $this->widgets[$widget->getId()] = $widget;
58
+    }
59 59
 
60
-	public function lazyRegisterWidget(string $widgetClass): void {
61
-		$this->lazyWidgets[] = $widgetClass;
62
-	}
60
+    public function lazyRegisterWidget(string $widgetClass): void {
61
+        $this->lazyWidgets[] = $widgetClass;
62
+    }
63 63
 
64
-	public function loadLazyPanels(): void {
65
-		$classes = $this->lazyWidgets;
66
-		foreach ($classes as $class) {
67
-			try {
68
-				/** @var IWidget $widget */
69
-				$widget = $this->serverContainer->query($class);
70
-			} catch (QueryException $e) {
71
-				/*
64
+    public function loadLazyPanels(): void {
65
+        $classes = $this->lazyWidgets;
66
+        foreach ($classes as $class) {
67
+            try {
68
+                /** @var IWidget $widget */
69
+                $widget = $this->serverContainer->query($class);
70
+            } catch (QueryException $e) {
71
+                /*
72 72
 				 * There is a circular dependency between the logger and the registry, so
73 73
 				 * we can not inject it. Thus the static call.
74 74
 				 */
75
-				\OC::$server->getLogger()->logException($e, [
76
-					'message' => 'Could not load lazy dashbaord widget: ' . $e->getMessage(),
77
-					'level' => ILogger::FATAL,
78
-				]);
79
-			}
80
-			/**
81
-			 * Try to register the loaded reporter. Theoretically it could be of a wrong
82
-			 * type, so we might get a TypeError here that we should catch.
83
-			 */
84
-			try {
85
-				$this->registerWidget($widget);
86
-			} catch (Throwable $e) {
87
-				/*
75
+                \OC::$server->getLogger()->logException($e, [
76
+                    'message' => 'Could not load lazy dashbaord widget: ' . $e->getMessage(),
77
+                    'level' => ILogger::FATAL,
78
+                ]);
79
+            }
80
+            /**
81
+             * Try to register the loaded reporter. Theoretically it could be of a wrong
82
+             * type, so we might get a TypeError here that we should catch.
83
+             */
84
+            try {
85
+                $this->registerWidget($widget);
86
+            } catch (Throwable $e) {
87
+                /*
88 88
 				 * There is a circular dependency between the logger and the registry, so
89 89
 				 * we can not inject it. Thus the static call.
90 90
 				 */
91
-				\OC::$server->getLogger()->logException($e, [
92
-					'message' => 'Could not register lazy dashboard widget: ' . $e->getMessage(),
93
-					'level' => ILogger::FATAL,
94
-				]);
95
-			}
91
+                \OC::$server->getLogger()->logException($e, [
92
+                    'message' => 'Could not register lazy dashboard widget: ' . $e->getMessage(),
93
+                    'level' => ILogger::FATAL,
94
+                ]);
95
+            }
96 96
 
97
-			try {
98
-				$startTime = microtime(true);
99
-				$widget->load();
100
-				$endTime = microtime(true);
101
-				$duration = $endTime - $startTime;
102
-				if ($duration > 1) {
103
-					\OC::$server->getLogger()->error('Dashboard widget {widget} took {duration} seconds to load.', [
104
-						'widget' => $widget->getId(),
105
-						'duration' => round($duration, 2),
106
-					]);
107
-				}
108
-			} catch (Throwable $e) {
109
-				\OC::$server->getLogger()->logException($e, [
110
-					'message' => 'Error during dashboard widget loading: ' . $e->getMessage(),
111
-					'level' => ILogger::FATAL,
112
-				]);
113
-			}
114
-		}
115
-		$this->lazyWidgets = [];
116
-	}
97
+            try {
98
+                $startTime = microtime(true);
99
+                $widget->load();
100
+                $endTime = microtime(true);
101
+                $duration = $endTime - $startTime;
102
+                if ($duration > 1) {
103
+                    \OC::$server->getLogger()->error('Dashboard widget {widget} took {duration} seconds to load.', [
104
+                        'widget' => $widget->getId(),
105
+                        'duration' => round($duration, 2),
106
+                    ]);
107
+                }
108
+            } catch (Throwable $e) {
109
+                \OC::$server->getLogger()->logException($e, [
110
+                    'message' => 'Error during dashboard widget loading: ' . $e->getMessage(),
111
+                    'level' => ILogger::FATAL,
112
+                ]);
113
+            }
114
+        }
115
+        $this->lazyWidgets = [];
116
+    }
117 117
 
118
-	public function getWidgets(): array {
119
-		$this->loadLazyPanels();
120
-		return $this->widgets;
121
-	}
118
+    public function getWidgets(): array {
119
+        $this->loadLazyPanels();
120
+        return $this->widgets;
121
+    }
122 122
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 				 * we can not inject it. Thus the static call.
74 74
 				 */
75 75
 				\OC::$server->getLogger()->logException($e, [
76
-					'message' => 'Could not load lazy dashbaord widget: ' . $e->getMessage(),
76
+					'message' => 'Could not load lazy dashbaord widget: '.$e->getMessage(),
77 77
 					'level' => ILogger::FATAL,
78 78
 				]);
79 79
 			}
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 				 * we can not inject it. Thus the static call.
90 90
 				 */
91 91
 				\OC::$server->getLogger()->logException($e, [
92
-					'message' => 'Could not register lazy dashboard widget: ' . $e->getMessage(),
92
+					'message' => 'Could not register lazy dashboard widget: '.$e->getMessage(),
93 93
 					'level' => ILogger::FATAL,
94 94
 				]);
95 95
 			}
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 				}
108 108
 			} catch (Throwable $e) {
109 109
 				\OC::$server->getLogger()->logException($e, [
110
-					'message' => 'Error during dashboard widget loading: ' . $e->getMessage(),
110
+					'message' => 'Error during dashboard widget loading: '.$e->getMessage(),
111 111
 					'level' => ILogger::FATAL,
112 112
 				]);
113 113
 			}
Please login to merge, or discard this patch.