Passed
Push — master ( 5fb7ea...32bbe3 )
by John
18:30 queued 13s
created
apps/files_external/lib/Settings/PersonalSection.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -29,25 +29,25 @@
 block discarded – undo
29 29
 use OCP\IUserSession;
30 30
 
31 31
 class PersonalSection extends Section {
32
-	/** @var IUserSession */
33
-	private $userSession;
32
+    /** @var IUserSession */
33
+    private $userSession;
34 34
 
35
-	/** @var UserGlobalStoragesService */
36
-	private $userGlobalStoragesService;
35
+    /** @var UserGlobalStoragesService */
36
+    private $userGlobalStoragesService;
37 37
 
38
-	/** @var BackendService */
39
-	private $backendService;
38
+    /** @var BackendService */
39
+    private $backendService;
40 40
 
41
-	public function __construct(
42
-		IURLGenerator $url,
43
-		IL10N $l,
44
-		IUserSession $userSession,
45
-		UserGlobalStoragesService $userGlobalStoragesService,
46
-		BackendService $backendService
47
-	) {
48
-		parent::__construct($url, $l);
49
-		$this->userSession = $userSession;
50
-		$this->userGlobalStoragesService = $userGlobalStoragesService;
51
-		$this->backendService = $backendService;
52
-	}
41
+    public function __construct(
42
+        IURLGenerator $url,
43
+        IL10N $l,
44
+        IUserSession $userSession,
45
+        UserGlobalStoragesService $userGlobalStoragesService,
46
+        BackendService $backendService
47
+    ) {
48
+        parent::__construct($url, $l);
49
+        $this->userSession = $userSession;
50
+        $this->userGlobalStoragesService = $userGlobalStoragesService;
51
+        $this->backendService = $backendService;
52
+    }
53 53
 }
Please login to merge, or discard this patch.
apps/testing/lib/Controller/ConfigController.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -29,39 +29,39 @@
 block discarded – undo
29 29
 
30 30
 class ConfigController extends OCSController {
31 31
 
32
-	/** @var IConfig */
33
-	private $config;
32
+    /** @var IConfig */
33
+    private $config;
34 34
 
35
-	/**
36
-	 * @param string $appName
37
-	 * @param IRequest $request
38
-	 * @param IConfig $config
39
-	 */
40
-	public function __construct($appName,
41
-								IRequest $request,
42
-								IConfig $config) {
43
-		parent::__construct($appName, $request);
44
-		$this->config = $config;
45
-	}
35
+    /**
36
+     * @param string $appName
37
+     * @param IRequest $request
38
+     * @param IConfig $config
39
+     */
40
+    public function __construct($appName,
41
+                                IRequest $request,
42
+                                IConfig $config) {
43
+        parent::__construct($appName, $request);
44
+        $this->config = $config;
45
+    }
46 46
 
47
-	/**
48
-	 * @param string $appid
49
-	 * @param string $configkey
50
-	 * @param string $value
51
-	 * @return DataResponse
52
-	 */
53
-	public function setAppValue($appid, $configkey, $value) {
54
-		$this->config->setAppValue($appid, $configkey, $value);
55
-		return new DataResponse();
56
-	}
47
+    /**
48
+     * @param string $appid
49
+     * @param string $configkey
50
+     * @param string $value
51
+     * @return DataResponse
52
+     */
53
+    public function setAppValue($appid, $configkey, $value) {
54
+        $this->config->setAppValue($appid, $configkey, $value);
55
+        return new DataResponse();
56
+    }
57 57
 
58
-	/**
59
-	 * @param string $appid
60
-	 * @param string $configkey
61
-	 * @return DataResponse
62
-	 */
63
-	public function deleteAppValue($appid, $configkey) {
64
-		$this->config->deleteAppValue($appid, $configkey);
65
-		return new DataResponse();
66
-	}
58
+    /**
59
+     * @param string $appid
60
+     * @param string $configkey
61
+     * @return DataResponse
62
+     */
63
+    public function deleteAppValue($appid, $configkey) {
64
+        $this->config->deleteAppValue($appid, $configkey);
65
+        return new DataResponse();
66
+    }
67 67
 }
Please login to merge, or discard this patch.
lib/public/IDateTimeFormatter.php 1 patch
Indentation   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -30,114 +30,114 @@
 block discarded – undo
30 30
  * @since 8.0.0
31 31
  */
32 32
 interface IDateTimeFormatter {
33
-	/**
34
-	 * Formats the date of the given timestamp
35
-	 *
36
-	 * @param int|\DateTime		$timestamp
37
-	 * @param string	$format			Either 'full', 'long', 'medium' or 'short'
38
-	 * 				full:	e.g. 'EEEE, MMMM d, y'	=> 'Wednesday, August 20, 2014'
39
-	 * 				long:	e.g. 'MMMM d, y'		=> 'August 20, 2014'
40
-	 * 				medium:	e.g. 'MMM d, y'			=> 'Aug 20, 2014'
41
-	 * 				short:	e.g. 'M/d/yy'			=> '8/20/14'
42
-	 * 				The exact format is dependent on the language
43
-	 * @param \DateTimeZone|null	$timeZone	The timezone to use
44
-	 * @param \OCP\IL10N|null	$l			The locale to use
45
-	 * @return string Formatted date string
46
-	 * @since 8.0.0
47
-	 */
48
-	public function formatDate($timestamp, $format = 'long', \DateTimeZone $timeZone = null, \OCP\IL10N $l = null);
33
+    /**
34
+     * Formats the date of the given timestamp
35
+     *
36
+     * @param int|\DateTime		$timestamp
37
+     * @param string	$format			Either 'full', 'long', 'medium' or 'short'
38
+     * 				full:	e.g. 'EEEE, MMMM d, y'	=> 'Wednesday, August 20, 2014'
39
+     * 				long:	e.g. 'MMMM d, y'		=> 'August 20, 2014'
40
+     * 				medium:	e.g. 'MMM d, y'			=> 'Aug 20, 2014'
41
+     * 				short:	e.g. 'M/d/yy'			=> '8/20/14'
42
+     * 				The exact format is dependent on the language
43
+     * @param \DateTimeZone|null	$timeZone	The timezone to use
44
+     * @param \OCP\IL10N|null	$l			The locale to use
45
+     * @return string Formatted date string
46
+     * @since 8.0.0
47
+     */
48
+    public function formatDate($timestamp, $format = 'long', \DateTimeZone $timeZone = null, \OCP\IL10N $l = null);
49 49
 
50
-	/**
51
-	 * Formats the date of the given timestamp
52
-	 *
53
-	 * @param int|\DateTime		$timestamp
54
-	 * @param string	$format			Either 'full', 'long', 'medium' or 'short'
55
-	 * 				full:	e.g. 'EEEE, MMMM d, y'	=> 'Wednesday, August 20, 2014'
56
-	 * 				long:	e.g. 'MMMM d, y'		=> 'August 20, 2014'
57
-	 * 				medium:	e.g. 'MMM d, y'			=> 'Aug 20, 2014'
58
-	 * 				short:	e.g. 'M/d/yy'			=> '8/20/14'
59
-	 * 				The exact format is dependent on the language
60
-	 * 					Uses 'Today', 'Yesterday' and 'Tomorrow' when applicable
61
-	 * @param \DateTimeZone|null	$timeZone	The timezone to use
62
-	 * @param \OCP\IL10N|null	$l			The locale to use
63
-	 * @return string Formatted relative date string
64
-	 * @since 8.0.0
65
-	 */
66
-	public function formatDateRelativeDay($timestamp, $format = 'long', \DateTimeZone $timeZone = null, \OCP\IL10N $l = null);
50
+    /**
51
+     * Formats the date of the given timestamp
52
+     *
53
+     * @param int|\DateTime		$timestamp
54
+     * @param string	$format			Either 'full', 'long', 'medium' or 'short'
55
+     * 				full:	e.g. 'EEEE, MMMM d, y'	=> 'Wednesday, August 20, 2014'
56
+     * 				long:	e.g. 'MMMM d, y'		=> 'August 20, 2014'
57
+     * 				medium:	e.g. 'MMM d, y'			=> 'Aug 20, 2014'
58
+     * 				short:	e.g. 'M/d/yy'			=> '8/20/14'
59
+     * 				The exact format is dependent on the language
60
+     * 					Uses 'Today', 'Yesterday' and 'Tomorrow' when applicable
61
+     * @param \DateTimeZone|null	$timeZone	The timezone to use
62
+     * @param \OCP\IL10N|null	$l			The locale to use
63
+     * @return string Formatted relative date string
64
+     * @since 8.0.0
65
+     */
66
+    public function formatDateRelativeDay($timestamp, $format = 'long', \DateTimeZone $timeZone = null, \OCP\IL10N $l = null);
67 67
 
68
-	/**
69
-	 * Gives the relative date of the timestamp
70
-	 * Only works for past dates
71
-	 *
72
-	 * @param int|\DateTime	$timestamp
73
-	 * @param int|\DateTime|null	$baseTimestamp	Timestamp to compare $timestamp against, defaults to current time
74
-	 * @param \OCP\IL10N|null		$l			The locale to use
75
-	 * @return string	Dates returned are:
76
-	 * 				<  1 month	=> Today, Yesterday, n days ago
77
-	 * 				< 13 month	=> last month, n months ago
78
-	 * 				>= 13 month	=> last year, n years ago
79
-	 * @since 8.0.0
80
-	 */
81
-	public function formatDateSpan($timestamp, $baseTimestamp = null, \OCP\IL10N $l = null);
68
+    /**
69
+     * Gives the relative date of the timestamp
70
+     * Only works for past dates
71
+     *
72
+     * @param int|\DateTime	$timestamp
73
+     * @param int|\DateTime|null	$baseTimestamp	Timestamp to compare $timestamp against, defaults to current time
74
+     * @param \OCP\IL10N|null		$l			The locale to use
75
+     * @return string	Dates returned are:
76
+     * 				<  1 month	=> Today, Yesterday, n days ago
77
+     * 				< 13 month	=> last month, n months ago
78
+     * 				>= 13 month	=> last year, n years ago
79
+     * @since 8.0.0
80
+     */
81
+    public function formatDateSpan($timestamp, $baseTimestamp = null, \OCP\IL10N $l = null);
82 82
 
83
-	/**
84
-	 * Formats the time of the given timestamp
85
-	 *
86
-	 * @param int|\DateTime $timestamp
87
-	 * @param string	$format			Either 'full', 'long', 'medium' or 'short'
88
-	 * 				full:	e.g. 'h:mm:ss a zzzz'	=> '11:42:13 AM GMT+0:00'
89
-	 * 				long:	e.g. 'h:mm:ss a z'		=> '11:42:13 AM GMT'
90
-	 * 				medium:	e.g. 'h:mm:ss a'		=> '11:42:13 AM'
91
-	 * 				short:	e.g. 'h:mm a'			=> '11:42 AM'
92
-	 * 				The exact format is dependent on the language
93
-	 * @param \DateTimeZone|null	$timeZone	The timezone to use
94
-	 * @param \OCP\IL10N|null		$l			The locale to use
95
-	 * @return string Formatted time string
96
-	 * @since 8.0.0
97
-	 */
98
-	public function formatTime($timestamp, $format = 'medium', \DateTimeZone $timeZone = null, \OCP\IL10N $l = null);
83
+    /**
84
+     * Formats the time of the given timestamp
85
+     *
86
+     * @param int|\DateTime $timestamp
87
+     * @param string	$format			Either 'full', 'long', 'medium' or 'short'
88
+     * 				full:	e.g. 'h:mm:ss a zzzz'	=> '11:42:13 AM GMT+0:00'
89
+     * 				long:	e.g. 'h:mm:ss a z'		=> '11:42:13 AM GMT'
90
+     * 				medium:	e.g. 'h:mm:ss a'		=> '11:42:13 AM'
91
+     * 				short:	e.g. 'h:mm a'			=> '11:42 AM'
92
+     * 				The exact format is dependent on the language
93
+     * @param \DateTimeZone|null	$timeZone	The timezone to use
94
+     * @param \OCP\IL10N|null		$l			The locale to use
95
+     * @return string Formatted time string
96
+     * @since 8.0.0
97
+     */
98
+    public function formatTime($timestamp, $format = 'medium', \DateTimeZone $timeZone = null, \OCP\IL10N $l = null);
99 99
 
100
-	/**
101
-	 * Gives the relative past time of the timestamp
102
-	 *
103
-	 * @param int|\DateTime	$timestamp
104
-	 * @param int|\DateTime|null	$baseTimestamp	Timestamp to compare $timestamp against, defaults to current time
105
-	 * @param \OCP\IL10N|null		$l			The locale to use
106
-	 * @return string	Dates returned are:
107
-	 * 				< 60 sec	=> seconds ago
108
-	 * 				<  1 hour	=> n minutes ago
109
-	 * 				<  1 day	=> n hours ago
110
-	 * 				<  1 month	=> Yesterday, n days ago
111
-	 * 				< 13 month	=> last month, n months ago
112
-	 * 				>= 13 month	=> last year, n years ago
113
-	 * @since 8.0.0
114
-	 */
115
-	public function formatTimeSpan($timestamp, $baseTimestamp = null, \OCP\IL10N $l = null);
100
+    /**
101
+     * Gives the relative past time of the timestamp
102
+     *
103
+     * @param int|\DateTime	$timestamp
104
+     * @param int|\DateTime|null	$baseTimestamp	Timestamp to compare $timestamp against, defaults to current time
105
+     * @param \OCP\IL10N|null		$l			The locale to use
106
+     * @return string	Dates returned are:
107
+     * 				< 60 sec	=> seconds ago
108
+     * 				<  1 hour	=> n minutes ago
109
+     * 				<  1 day	=> n hours ago
110
+     * 				<  1 month	=> Yesterday, n days ago
111
+     * 				< 13 month	=> last month, n months ago
112
+     * 				>= 13 month	=> last year, n years ago
113
+     * @since 8.0.0
114
+     */
115
+    public function formatTimeSpan($timestamp, $baseTimestamp = null, \OCP\IL10N $l = null);
116 116
 
117
-	/**
118
-	 * Formats the date and time of the given timestamp
119
-	 *
120
-	 * @param int|\DateTime $timestamp
121
-	 * @param string	$formatDate		See formatDate() for description
122
-	 * @param string	$formatTime		See formatTime() for description
123
-	 * @param \DateTimeZone|null	$timeZone	The timezone to use
124
-	 * @param \OCP\IL10N|null		$l			The locale to use
125
-	 * @return string Formatted date and time string
126
-	 * @since 8.0.0
127
-	 */
128
-	public function formatDateTime($timestamp, $formatDate = 'long', $formatTime = 'medium', \DateTimeZone $timeZone = null, \OCP\IL10N $l = null);
117
+    /**
118
+     * Formats the date and time of the given timestamp
119
+     *
120
+     * @param int|\DateTime $timestamp
121
+     * @param string	$formatDate		See formatDate() for description
122
+     * @param string	$formatTime		See formatTime() for description
123
+     * @param \DateTimeZone|null	$timeZone	The timezone to use
124
+     * @param \OCP\IL10N|null		$l			The locale to use
125
+     * @return string Formatted date and time string
126
+     * @since 8.0.0
127
+     */
128
+    public function formatDateTime($timestamp, $formatDate = 'long', $formatTime = 'medium', \DateTimeZone $timeZone = null, \OCP\IL10N $l = null);
129 129
 
130
-	/**
131
-	 * Formats the date and time of the given timestamp
132
-	 *
133
-	 * @param int|\DateTime $timestamp
134
-	 * @param string	$formatDate		See formatDate() for description
135
-	 * 					Uses 'Today', 'Yesterday' and 'Tomorrow' when applicable
136
-	 * @param string	$formatTime		See formatTime() for description
137
-	 * @param \DateTimeZone|null	$timeZone	The timezone to use
138
-	 * @param \OCP\IL10N|null		$l			The locale to use
139
-	 * @return string Formatted relative date and time string
140
-	 * @since 8.0.0
141
-	 */
142
-	public function formatDateTimeRelativeDay($timestamp, $formatDate = 'long', $formatTime = 'medium', \DateTimeZone $timeZone = null, \OCP\IL10N $l = null);
130
+    /**
131
+     * Formats the date and time of the given timestamp
132
+     *
133
+     * @param int|\DateTime $timestamp
134
+     * @param string	$formatDate		See formatDate() for description
135
+     * 					Uses 'Today', 'Yesterday' and 'Tomorrow' when applicable
136
+     * @param string	$formatTime		See formatTime() for description
137
+     * @param \DateTimeZone|null	$timeZone	The timezone to use
138
+     * @param \OCP\IL10N|null		$l			The locale to use
139
+     * @return string Formatted relative date and time string
140
+     * @since 8.0.0
141
+     */
142
+    public function formatDateTimeRelativeDay($timestamp, $formatDate = 'long', $formatTime = 'medium', \DateTimeZone $timeZone = null, \OCP\IL10N $l = null);
143 143
 }
Please login to merge, or discard this patch.
files_external/lib/Lib/InsufficientDataForMeaningfulAnswerException.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -29,15 +29,15 @@
 block discarded – undo
29 29
  * Authentication mechanism or backend has insufficient data
30 30
  */
31 31
 class InsufficientDataForMeaningfulAnswerException extends StorageNotAvailableException {
32
-	/**
33
-	 * StorageNotAvailableException constructor.
34
-	 *
35
-	 * @param string $message
36
-	 * @param int $code
37
-	 * @param \Exception|null $previous
38
-	 * @since 6.0.0
39
-	 */
40
-	public function __construct($message = '', $code = self::STATUS_INDETERMINATE, \Exception $previous = null) {
41
-		parent::__construct($message, $code, $previous);
42
-	}
32
+    /**
33
+     * StorageNotAvailableException constructor.
34
+     *
35
+     * @param string $message
36
+     * @param int $code
37
+     * @param \Exception|null $previous
38
+     * @since 6.0.0
39
+     */
40
+    public function __construct($message = '', $code = self::STATUS_INDETERMINATE, \Exception $previous = null) {
41
+        parent::__construct($message, $code, $previous);
42
+    }
43 43
 }
Please login to merge, or discard this patch.
lib/public/AppFramework/Controller.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 
79 79
 		// default responders
80 80
 		$this->responders = [
81
-			'json' => function ($data) {
81
+			'json' => function($data) {
82 82
 				if ($data instanceof DataResponse) {
83 83
 					$response = new JSONResponse(
84 84
 						$data->getData(),
@@ -153,6 +153,6 @@  discard block
 block discarded – undo
153 153
 			return $responder($response);
154 154
 		}
155 155
 		throw new \DomainException('No responder registered for format '.
156
-			$format . '!');
156
+			$format.'!');
157 157
 	}
158 158
 }
Please login to merge, or discard this patch.
Indentation   +121 added lines, -121 removed lines patch added patch discarded remove patch
@@ -38,125 +38,125 @@
 block discarded – undo
38 38
  * @since 6.0.0
39 39
  */
40 40
 abstract class Controller {
41
-	/**
42
-	 * app name
43
-	 * @var string
44
-	 * @since 7.0.0
45
-	 */
46
-	protected $appName;
47
-
48
-	/**
49
-	 * current request
50
-	 * @var \OCP\IRequest
51
-	 * @since 6.0.0
52
-	 */
53
-	protected $request;
54
-
55
-	/**
56
-	 * @var array
57
-	 * @since 7.0.0
58
-	 */
59
-	private $responders;
60
-
61
-	/**
62
-	 * constructor of the controller
63
-	 * @param string $appName the name of the app
64
-	 * @param IRequest $request an instance of the request
65
-	 * @since 6.0.0 - parameter $appName was added in 7.0.0 - parameter $app was removed in 7.0.0
66
-	 */
67
-	public function __construct($appName,
68
-								IRequest $request) {
69
-		$this->appName = $appName;
70
-		$this->request = $request;
71
-
72
-		// default responders
73
-		$this->responders = [
74
-			'json' => function ($data) {
75
-				if ($data instanceof DataResponse) {
76
-					$response = new JSONResponse(
77
-						$data->getData(),
78
-						$data->getStatus()
79
-					);
80
-					$dataHeaders = $data->getHeaders();
81
-					$headers = $response->getHeaders();
82
-					// do not overwrite Content-Type if it already exists
83
-					if (isset($dataHeaders['Content-Type'])) {
84
-						unset($headers['Content-Type']);
85
-					}
86
-					$response->setHeaders(array_merge($dataHeaders, $headers));
87
-
88
-					if ($data->getETag() !== null) {
89
-						$response->setETag($data->getETag());
90
-					}
91
-					if ($data->getLastModified() !== null) {
92
-						$response->setLastModified($data->getLastModified());
93
-					}
94
-					if ($data->isThrottled()) {
95
-						$response->throttle($data->getThrottleMetadata());
96
-					}
97
-
98
-					return $response;
99
-				}
100
-				return new JSONResponse($data);
101
-			}
102
-		];
103
-	}
104
-
105
-
106
-	/**
107
-	 * Parses an HTTP accept header and returns the supported responder type
108
-	 * @param string $acceptHeader
109
-	 * @param string $default
110
-	 * @return string the responder type
111
-	 * @since 7.0.0
112
-	 * @since 9.1.0 Added default parameter
113
-	 */
114
-	public function getResponderByHTTPHeader($acceptHeader, $default = 'json') {
115
-		$headers = explode(',', $acceptHeader);
116
-
117
-		// return the first matching responder
118
-		foreach ($headers as $header) {
119
-			$header = strtolower(trim($header));
120
-
121
-			$responder = str_replace('application/', '', $header);
122
-
123
-			if (array_key_exists($responder, $this->responders)) {
124
-				return $responder;
125
-			}
126
-		}
127
-
128
-		// no matching header return default
129
-		return $default;
130
-	}
131
-
132
-
133
-	/**
134
-	 * Registers a formatter for a type
135
-	 * @param string $format
136
-	 * @param \Closure $responder
137
-	 * @since 7.0.0
138
-	 */
139
-	protected function registerResponder($format, \Closure $responder) {
140
-		$this->responders[$format] = $responder;
141
-	}
142
-
143
-
144
-	/**
145
-	 * Serializes and formats a response
146
-	 * @param mixed $response the value that was returned from a controller and
147
-	 * is not a Response instance
148
-	 * @param string $format the format for which a formatter has been registered
149
-	 * @throws \DomainException if format does not match a registered formatter
150
-	 * @return Response
151
-	 * @since 7.0.0
152
-	 */
153
-	public function buildResponse($response, $format = 'json') {
154
-		if (array_key_exists($format, $this->responders)) {
155
-			$responder = $this->responders[$format];
156
-
157
-			return $responder($response);
158
-		}
159
-		throw new \DomainException('No responder registered for format '.
160
-			$format . '!');
161
-	}
41
+    /**
42
+     * app name
43
+     * @var string
44
+     * @since 7.0.0
45
+     */
46
+    protected $appName;
47
+
48
+    /**
49
+     * current request
50
+     * @var \OCP\IRequest
51
+     * @since 6.0.0
52
+     */
53
+    protected $request;
54
+
55
+    /**
56
+     * @var array
57
+     * @since 7.0.0
58
+     */
59
+    private $responders;
60
+
61
+    /**
62
+     * constructor of the controller
63
+     * @param string $appName the name of the app
64
+     * @param IRequest $request an instance of the request
65
+     * @since 6.0.0 - parameter $appName was added in 7.0.0 - parameter $app was removed in 7.0.0
66
+     */
67
+    public function __construct($appName,
68
+                                IRequest $request) {
69
+        $this->appName = $appName;
70
+        $this->request = $request;
71
+
72
+        // default responders
73
+        $this->responders = [
74
+            'json' => function ($data) {
75
+                if ($data instanceof DataResponse) {
76
+                    $response = new JSONResponse(
77
+                        $data->getData(),
78
+                        $data->getStatus()
79
+                    );
80
+                    $dataHeaders = $data->getHeaders();
81
+                    $headers = $response->getHeaders();
82
+                    // do not overwrite Content-Type if it already exists
83
+                    if (isset($dataHeaders['Content-Type'])) {
84
+                        unset($headers['Content-Type']);
85
+                    }
86
+                    $response->setHeaders(array_merge($dataHeaders, $headers));
87
+
88
+                    if ($data->getETag() !== null) {
89
+                        $response->setETag($data->getETag());
90
+                    }
91
+                    if ($data->getLastModified() !== null) {
92
+                        $response->setLastModified($data->getLastModified());
93
+                    }
94
+                    if ($data->isThrottled()) {
95
+                        $response->throttle($data->getThrottleMetadata());
96
+                    }
97
+
98
+                    return $response;
99
+                }
100
+                return new JSONResponse($data);
101
+            }
102
+        ];
103
+    }
104
+
105
+
106
+    /**
107
+     * Parses an HTTP accept header and returns the supported responder type
108
+     * @param string $acceptHeader
109
+     * @param string $default
110
+     * @return string the responder type
111
+     * @since 7.0.0
112
+     * @since 9.1.0 Added default parameter
113
+     */
114
+    public function getResponderByHTTPHeader($acceptHeader, $default = 'json') {
115
+        $headers = explode(',', $acceptHeader);
116
+
117
+        // return the first matching responder
118
+        foreach ($headers as $header) {
119
+            $header = strtolower(trim($header));
120
+
121
+            $responder = str_replace('application/', '', $header);
122
+
123
+            if (array_key_exists($responder, $this->responders)) {
124
+                return $responder;
125
+            }
126
+        }
127
+
128
+        // no matching header return default
129
+        return $default;
130
+    }
131
+
132
+
133
+    /**
134
+     * Registers a formatter for a type
135
+     * @param string $format
136
+     * @param \Closure $responder
137
+     * @since 7.0.0
138
+     */
139
+    protected function registerResponder($format, \Closure $responder) {
140
+        $this->responders[$format] = $responder;
141
+    }
142
+
143
+
144
+    /**
145
+     * Serializes and formats a response
146
+     * @param mixed $response the value that was returned from a controller and
147
+     * is not a Response instance
148
+     * @param string $format the format for which a formatter has been registered
149
+     * @throws \DomainException if format does not match a registered formatter
150
+     * @return Response
151
+     * @since 7.0.0
152
+     */
153
+    public function buildResponse($response, $format = 'json') {
154
+        if (array_key_exists($format, $this->responders)) {
155
+            $responder = $this->responders[$format];
156
+
157
+            return $responder($response);
158
+        }
159
+        throw new \DomainException('No responder registered for format '.
160
+            $format . '!');
161
+    }
162 162
 }
Please login to merge, or discard this patch.
lib/public/AppFramework/OCS/OCSNotFoundException.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -32,14 +32,14 @@
 block discarded – undo
32 32
  * @since 9.1.0
33 33
  */
34 34
 class OCSNotFoundException extends OCSException {
35
-	/**
36
-	 * OCSNotFoundException constructor.
37
-	 *
38
-	 * @param string $message
39
-	 * @param Exception|null $previous
40
-	 * @since 9.1.0
41
-	 */
42
-	public function __construct($message = '', Exception $previous = null) {
43
-		parent::__construct($message, Http::STATUS_NOT_FOUND, $previous);
44
-	}
35
+    /**
36
+     * OCSNotFoundException constructor.
37
+     *
38
+     * @param string $message
39
+     * @param Exception|null $previous
40
+     * @since 9.1.0
41
+     */
42
+    public function __construct($message = '', Exception $previous = null) {
43
+        parent::__construct($message, Http::STATUS_NOT_FOUND, $previous);
44
+    }
45 45
 }
Please login to merge, or discard this patch.
lib/public/AppFramework/OCS/OCSForbiddenException.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -32,14 +32,14 @@
 block discarded – undo
32 32
  * @since 9.1.0
33 33
  */
34 34
 class OCSForbiddenException extends OCSException {
35
-	/**
36
-	 * OCSForbiddenException constructor.
37
-	 *
38
-	 * @param string $message
39
-	 * @param Exception|null $previous
40
-	 * @since 9.1.0
41
-	 */
42
-	public function __construct($message = '', Exception $previous = null) {
43
-		parent::__construct($message, Http::STATUS_FORBIDDEN, $previous);
44
-	}
35
+    /**
36
+     * OCSForbiddenException constructor.
37
+     *
38
+     * @param string $message
39
+     * @param Exception|null $previous
40
+     * @since 9.1.0
41
+     */
42
+    public function __construct($message = '', Exception $previous = null) {
43
+        parent::__construct($message, Http::STATUS_FORBIDDEN, $previous);
44
+    }
45 45
 }
Please login to merge, or discard this patch.
lib/public/AppFramework/OCS/OCSBadRequestException.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -32,14 +32,14 @@
 block discarded – undo
32 32
  * @since 9.1.0
33 33
  */
34 34
 class OCSBadRequestException extends OCSException {
35
-	/**
36
-	 * OCSBadRequestException constructor.
37
-	 *
38
-	 * @param string $message
39
-	 * @param Exception|null $previous
40
-	 * @since 9.1.0
41
-	 */
42
-	public function __construct($message = '', Exception $previous = null) {
43
-		parent::__construct($message, Http::STATUS_BAD_REQUEST, $previous);
44
-	}
35
+    /**
36
+     * OCSBadRequestException constructor.
37
+     *
38
+     * @param string $message
39
+     * @param Exception|null $previous
40
+     * @since 9.1.0
41
+     */
42
+    public function __construct($message = '', Exception $previous = null) {
43
+        parent::__construct($message, Http::STATUS_BAD_REQUEST, $previous);
44
+    }
45 45
 }
Please login to merge, or discard this patch.
lib/public/AppFramework/Http/FileDisplayResponse.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 		$this->file = $file;
52 52
 		$this->setStatus($statusCode);
53 53
 		$this->setHeaders(array_merge($this->getHeaders(), $headers));
54
-		$this->addHeader('Content-Disposition', 'inline; filename="' . rawurldecode($file->getName()) . '"');
54
+		$this->addHeader('Content-Disposition', 'inline; filename="'.rawurldecode($file->getName()).'"');
55 55
 
56 56
 		$this->setETag($file->getEtag());
57 57
 		$lastModified = new \DateTime();
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 	 */
66 66
 	public function callback(IOutput $output) {
67 67
 		if ($output->getHttpResponseCode() !== Http::STATUS_NOT_MODIFIED) {
68
-			$output->setHeader('Content-Length: ' . $this->file->getSize());
68
+			$output->setHeader('Content-Length: '.$this->file->getSize());
69 69
 			$output->setOutput($this->file->getContent());
70 70
 		}
71 71
 	}
Please login to merge, or discard this patch.
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -31,40 +31,40 @@
 block discarded – undo
31 31
  * @since 11.0.0
32 32
  */
33 33
 class FileDisplayResponse extends Response implements ICallbackResponse {
34
-	/** @var \OCP\Files\File|\OCP\Files\SimpleFS\ISimpleFile */
35
-	private $file;
34
+    /** @var \OCP\Files\File|\OCP\Files\SimpleFS\ISimpleFile */
35
+    private $file;
36 36
 
37
-	/**
38
-	 * FileDisplayResponse constructor.
39
-	 *
40
-	 * @param \OCP\Files\File|\OCP\Files\SimpleFS\ISimpleFile $file
41
-	 * @param int $statusCode
42
-	 * @param array $headers
43
-	 * @since 11.0.0
44
-	 */
45
-	public function __construct($file, $statusCode = Http::STATUS_OK,
46
-								$headers = []) {
47
-		parent::__construct();
37
+    /**
38
+     * FileDisplayResponse constructor.
39
+     *
40
+     * @param \OCP\Files\File|\OCP\Files\SimpleFS\ISimpleFile $file
41
+     * @param int $statusCode
42
+     * @param array $headers
43
+     * @since 11.0.0
44
+     */
45
+    public function __construct($file, $statusCode = Http::STATUS_OK,
46
+                                $headers = []) {
47
+        parent::__construct();
48 48
 
49
-		$this->file = $file;
50
-		$this->setStatus($statusCode);
51
-		$this->setHeaders(array_merge($this->getHeaders(), $headers));
52
-		$this->addHeader('Content-Disposition', 'inline; filename="' . rawurldecode($file->getName()) . '"');
49
+        $this->file = $file;
50
+        $this->setStatus($statusCode);
51
+        $this->setHeaders(array_merge($this->getHeaders(), $headers));
52
+        $this->addHeader('Content-Disposition', 'inline; filename="' . rawurldecode($file->getName()) . '"');
53 53
 
54
-		$this->setETag($file->getEtag());
55
-		$lastModified = new \DateTime();
56
-		$lastModified->setTimestamp($file->getMTime());
57
-		$this->setLastModified($lastModified);
58
-	}
54
+        $this->setETag($file->getEtag());
55
+        $lastModified = new \DateTime();
56
+        $lastModified->setTimestamp($file->getMTime());
57
+        $this->setLastModified($lastModified);
58
+    }
59 59
 
60
-	/**
61
-	 * @param IOutput $output
62
-	 * @since 11.0.0
63
-	 */
64
-	public function callback(IOutput $output) {
65
-		if ($output->getHttpResponseCode() !== Http::STATUS_NOT_MODIFIED) {
66
-			$output->setHeader('Content-Length: ' . $this->file->getSize());
67
-			$output->setOutput($this->file->getContent());
68
-		}
69
-	}
60
+    /**
61
+     * @param IOutput $output
62
+     * @since 11.0.0
63
+     */
64
+    public function callback(IOutput $output) {
65
+        if ($output->getHttpResponseCode() !== Http::STATUS_NOT_MODIFIED) {
66
+            $output->setHeader('Content-Length: ' . $this->file->getSize());
67
+            $output->setOutput($this->file->getContent());
68
+        }
69
+    }
70 70
 }
Please login to merge, or discard this patch.