Passed
Push — master ( 9daf35...060dd3 )
by Roeland
21:10 queued 10:01
created
lib/public/Files/StorageNotAvailableException.php 1 patch
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -40,50 +40,50 @@
 block discarded – undo
40 40
  */
41 41
 class StorageNotAvailableException extends HintException {
42 42
 
43
-	const STATUS_SUCCESS = 0;
44
-	const STATUS_ERROR = 1;
45
-	const STATUS_INDETERMINATE = 2;
46
-	const STATUS_INCOMPLETE_CONF = 3;
47
-	const STATUS_UNAUTHORIZED = 4;
48
-	const STATUS_TIMEOUT = 5;
49
-	const STATUS_NETWORK_ERROR = 6;
43
+    const STATUS_SUCCESS = 0;
44
+    const STATUS_ERROR = 1;
45
+    const STATUS_INDETERMINATE = 2;
46
+    const STATUS_INCOMPLETE_CONF = 3;
47
+    const STATUS_UNAUTHORIZED = 4;
48
+    const STATUS_TIMEOUT = 5;
49
+    const STATUS_NETWORK_ERROR = 6;
50 50
 
51
-	/**
52
-	 * StorageNotAvailableException constructor.
53
-	 *
54
-	 * @param string $message
55
-	 * @param int $code
56
-	 * @param \Exception|null $previous
57
-	 * @since 6.0.0
58
-	 */
59
-	public function __construct($message = '', $code = self::STATUS_ERROR, \Exception $previous = null) {
60
-		$l = \OC::$server->getL10N('core');
61
-		parent::__construct($message, $l->t('Storage is temporarily not available'), $code, $previous);
62
-	}
51
+    /**
52
+     * StorageNotAvailableException constructor.
53
+     *
54
+     * @param string $message
55
+     * @param int $code
56
+     * @param \Exception|null $previous
57
+     * @since 6.0.0
58
+     */
59
+    public function __construct($message = '', $code = self::STATUS_ERROR, \Exception $previous = null) {
60
+        $l = \OC::$server->getL10N('core');
61
+        parent::__construct($message, $l->t('Storage is temporarily not available'), $code, $previous);
62
+    }
63 63
 
64
-	/**
65
-	 * Get the name for a status code
66
-	 *
67
-	 * @param int $code
68
-	 * @return string
69
-	 * @since 9.0.0
70
-	 */
71
-	public static function getStateCodeName($code) {
72
-		switch ($code) {
73
-			case self::STATUS_SUCCESS:
74
-				return 'ok';
75
-			case self::STATUS_ERROR:
76
-				return 'error';
77
-			case self::STATUS_INDETERMINATE:
78
-				return 'indeterminate';
79
-			case self::STATUS_UNAUTHORIZED:
80
-				return 'unauthorized';
81
-			case self::STATUS_TIMEOUT:
82
-				return 'timeout';
83
-			case self::STATUS_NETWORK_ERROR:
84
-				return 'network error';
85
-			default:
86
-				return 'unknown';
87
-		}
88
-	}
64
+    /**
65
+     * Get the name for a status code
66
+     *
67
+     * @param int $code
68
+     * @return string
69
+     * @since 9.0.0
70
+     */
71
+    public static function getStateCodeName($code) {
72
+        switch ($code) {
73
+            case self::STATUS_SUCCESS:
74
+                return 'ok';
75
+            case self::STATUS_ERROR:
76
+                return 'error';
77
+            case self::STATUS_INDETERMINATE:
78
+                return 'indeterminate';
79
+            case self::STATUS_UNAUTHORIZED:
80
+                return 'unauthorized';
81
+            case self::STATUS_TIMEOUT:
82
+                return 'timeout';
83
+            case self::STATUS_NETWORK_ERROR:
84
+                return 'network error';
85
+            default:
86
+                return 'unknown';
87
+        }
88
+    }
89 89
 }
Please login to merge, or discard this patch.
lib/public/Files/ForbiddenException.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -32,25 +32,25 @@
 block discarded – undo
32 32
  */
33 33
 class ForbiddenException extends \Exception {
34 34
 
35
-	/** @var bool */
36
-	private $retry;
35
+    /** @var bool */
36
+    private $retry;
37 37
 
38
-	/**
39
-	 * @param string $message
40
-	 * @param bool $retry
41
-	 * @param \Exception|null $previous previous exception for cascading
42
-	 * @since 9.0.0
43
-	 */
44
-	public function __construct($message, $retry, \Exception $previous = null) {
45
-		parent::__construct($message, 0, $previous);
46
-		$this->retry = $retry;
47
-	}
38
+    /**
39
+     * @param string $message
40
+     * @param bool $retry
41
+     * @param \Exception|null $previous previous exception for cascading
42
+     * @since 9.0.0
43
+     */
44
+    public function __construct($message, $retry, \Exception $previous = null) {
45
+        parent::__construct($message, 0, $previous);
46
+        $this->retry = $retry;
47
+    }
48 48
 
49
-	/**
50
-	 * @return bool
51
-	 * @since 9.0.0
52
-	 */
53
-	public function getRetry() {
54
-		return (bool) $this->retry;
55
-	}
49
+    /**
50
+     * @return bool
51
+     * @since 9.0.0
52
+     */
53
+    public function getRetry() {
54
+        return (bool) $this->retry;
55
+    }
56 56
 }
Please login to merge, or discard this patch.
lib/public/Files/StorageTimeoutException.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -27,15 +27,15 @@
 block discarded – undo
27 27
  */
28 28
 class StorageTimeoutException extends StorageNotAvailableException {
29 29
 
30
-	/**
31
-	 * StorageTimeoutException constructor.
32
-	 *
33
-	 * @param string $message
34
-	 * @param \Exception|null $previous
35
-	 * @since 9.0.0
36
-	 */
37
-	public function __construct($message = '', \Exception $previous = null) {
38
-		$l = \OC::$server->getL10N('core');
39
-		parent::__construct($l->t('Storage connection timeout. %s', [$message]), self::STATUS_TIMEOUT, $previous);
40
-	}
30
+    /**
31
+     * StorageTimeoutException constructor.
32
+     *
33
+     * @param string $message
34
+     * @param \Exception|null $previous
35
+     * @since 9.0.0
36
+     */
37
+    public function __construct($message = '', \Exception $previous = null) {
38
+        $l = \OC::$server->getL10N('core');
39
+        parent::__construct($l->t('Storage connection timeout. %s', [$message]), self::STATUS_TIMEOUT, $previous);
40
+    }
41 41
 }
Please login to merge, or discard this patch.
lib/public/Files/SimpleFS/ISimpleFolder.php 1 patch
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -32,56 +32,56 @@
 block discarded – undo
32 32
  * @since 11.0.0
33 33
  */
34 34
 interface ISimpleFolder {
35
-	/**
36
-	 * Get all the files in a folder
37
-	 *
38
-	 * @return ISimpleFile[]
39
-	 * @since 11.0.0
40
-	 */
41
-	public function getDirectoryListing();
35
+    /**
36
+     * Get all the files in a folder
37
+     *
38
+     * @return ISimpleFile[]
39
+     * @since 11.0.0
40
+     */
41
+    public function getDirectoryListing();
42 42
 
43
-	/**
44
-	 * Check if a file with $name exists
45
-	 *
46
-	 * @param string $name
47
-	 * @return bool
48
-	 * @since 11.0.0
49
-	 */
50
-	public function fileExists($name);
43
+    /**
44
+     * Check if a file with $name exists
45
+     *
46
+     * @param string $name
47
+     * @return bool
48
+     * @since 11.0.0
49
+     */
50
+    public function fileExists($name);
51 51
 
52
-	/**
53
-	 * Get the file named $name from the folder
54
-	 *
55
-	 * @param string $name
56
-	 * @return ISimpleFile
57
-	 * @throws NotFoundException
58
-	 * @since 11.0.0
59
-	 */
60
-	public function getFile($name);
52
+    /**
53
+     * Get the file named $name from the folder
54
+     *
55
+     * @param string $name
56
+     * @return ISimpleFile
57
+     * @throws NotFoundException
58
+     * @since 11.0.0
59
+     */
60
+    public function getFile($name);
61 61
 
62
-	/**
63
-	 * Creates a new file with $name in the folder
64
-	 *
65
-	 * @param string $name
66
-	 * @return ISimpleFile
67
-	 * @throws NotPermittedException
68
-	 * @since 11.0.0
69
-	 */
70
-	public function newFile($name);
62
+    /**
63
+     * Creates a new file with $name in the folder
64
+     *
65
+     * @param string $name
66
+     * @return ISimpleFile
67
+     * @throws NotPermittedException
68
+     * @since 11.0.0
69
+     */
70
+    public function newFile($name);
71 71
 
72
-	/**
73
-	 * Remove the folder and all the files in it
74
-	 *
75
-	 * @throws NotPermittedException
76
-	 * @since 11.0.0
77
-	 */
78
-	public function delete();
72
+    /**
73
+     * Remove the folder and all the files in it
74
+     *
75
+     * @throws NotPermittedException
76
+     * @since 11.0.0
77
+     */
78
+    public function delete();
79 79
 
80
-	/**
81
-	 * Get the folder name
82
-	 *
83
-	 * @return string
84
-	 * @since 11.0.0
85
-	 */
86
-	public function getName();
80
+    /**
81
+     * Get the folder name
82
+     *
83
+     * @return string
84
+     * @since 11.0.0
85
+     */
86
+    public function getName();
87 87
 }
Please login to merge, or discard this patch.
lib/public/Files/StorageConnectionException.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -27,15 +27,15 @@
 block discarded – undo
27 27
  */
28 28
 class StorageConnectionException extends StorageNotAvailableException {
29 29
 
30
-	/**
31
-	 * StorageConnectionException constructor.
32
-	 *
33
-	 * @param string $message
34
-	 * @param \Exception|null $previous
35
-	 * @since 9.0.0
36
-	 */
37
-	public function __construct($message = '', \Exception $previous = null) {
38
-		$l = \OC::$server->getL10N('core');
39
-		parent::__construct($l->t('Storage connection error. %s', [$message]), self::STATUS_NETWORK_ERROR, $previous);
40
-	}
30
+    /**
31
+     * StorageConnectionException constructor.
32
+     *
33
+     * @param string $message
34
+     * @param \Exception|null $previous
35
+     * @since 9.0.0
36
+     */
37
+    public function __construct($message = '', \Exception $previous = null) {
38
+        $l = \OC::$server->getL10N('core');
39
+        parent::__construct($l->t('Storage connection error. %s', [$message]), self::STATUS_NETWORK_ERROR, $previous);
40
+    }
41 41
 }
Please login to merge, or discard this patch.
core/Controller/ContactsMenuController.php 1 patch
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -33,46 +33,46 @@
 block discarded – undo
33 33
 
34 34
 class ContactsMenuController extends Controller {
35 35
 
36
-	/** @var Manager */
37
-	private $manager;
36
+    /** @var Manager */
37
+    private $manager;
38 38
 
39
-	/** @var IUserSession */
40
-	private $userSession;
39
+    /** @var IUserSession */
40
+    private $userSession;
41 41
 
42
-	/**
43
-	 * @param IRequest $request
44
-	 * @param IUserSession $userSession
45
-	 * @param Manager $manager
46
-	 */
47
-	public function __construct(IRequest $request, IUserSession $userSession, Manager $manager) {
48
-		parent::__construct('core', $request);
49
-		$this->userSession = $userSession;
50
-		$this->manager = $manager;
51
-	}
42
+    /**
43
+     * @param IRequest $request
44
+     * @param IUserSession $userSession
45
+     * @param Manager $manager
46
+     */
47
+    public function __construct(IRequest $request, IUserSession $userSession, Manager $manager) {
48
+        parent::__construct('core', $request);
49
+        $this->userSession = $userSession;
50
+        $this->manager = $manager;
51
+    }
52 52
 
53
-	/**
54
-	 * @NoAdminRequired
55
-	 *
56
-	 * @param string|null filter
57
-	 * @return \JsonSerializable[]
58
-	 */
59
-	public function index($filter = null) {
60
-		return $this->manager->getEntries($this->userSession->getUser(), $filter);
61
-	}
53
+    /**
54
+     * @NoAdminRequired
55
+     *
56
+     * @param string|null filter
57
+     * @return \JsonSerializable[]
58
+     */
59
+    public function index($filter = null) {
60
+        return $this->manager->getEntries($this->userSession->getUser(), $filter);
61
+    }
62 62
 
63
-	/**
64
-	 * @NoAdminRequired
65
-	 *
66
-	 * @param integer $shareType
67
-	 * @param string $shareWith
68
-	 * @return JSONResponse|\JsonSerializable
69
-	 */
70
-	public function findOne($shareType, $shareWith) {
71
-		$contact = $this->manager->findOne($this->userSession->getUser(), $shareType, $shareWith);
63
+    /**
64
+     * @NoAdminRequired
65
+     *
66
+     * @param integer $shareType
67
+     * @param string $shareWith
68
+     * @return JSONResponse|\JsonSerializable
69
+     */
70
+    public function findOne($shareType, $shareWith) {
71
+        $contact = $this->manager->findOne($this->userSession->getUser(), $shareType, $shareWith);
72 72
 
73
-		if ($contact) {
74
-			return $contact;
75
-		}
76
-		return new JSONResponse([], Http::STATUS_NOT_FOUND);
77
-	}
73
+        if ($contact) {
74
+            return $contact;
75
+        }
76
+        return new JSONResponse([], Http::STATUS_NOT_FOUND);
77
+    }
78 78
 }
Please login to merge, or discard this patch.
apps/comments/appinfo/routes.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
  */
22 22
 
23 23
 return [
24
-	'routes' => [
25
-		['name' => 'Notifications#view', 'url' => '/notifications/view/{id}', 'verb' => 'GET'],
26
-	]
24
+    'routes' => [
25
+        ['name' => 'Notifications#view', 'url' => '/notifications/view/{id}', 'verb' => 'GET'],
26
+    ]
27 27
 ];
Please login to merge, or discard this patch.
apps/files_external/lib/Lib/Backend/Backend.php 1 patch
Indentation   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -57,110 +57,110 @@
 block discarded – undo
57 57
  */
58 58
 class Backend implements \JsonSerializable {
59 59
 
60
-	use VisibilityTrait;
61
-	use FrontendDefinitionTrait;
62
-	use PriorityTrait;
63
-	use DependencyTrait;
64
-	use StorageModifierTrait;
65
-	use IdentifierTrait;
66
-
67
-	/** @var string storage class */
68
-	private $storageClass;
69
-
70
-	/** @var array 'scheme' => true, supported authentication schemes */
71
-	private $authSchemes = [];
72
-
73
-	/** @var AuthMechanism|callable authentication mechanism fallback */
74
-	private $legacyAuthMechanism;
75
-
76
-	/**
77
-	 * @return string
78
-	 */
79
-	public function getStorageClass() {
80
-		return $this->storageClass;
81
-	}
82
-
83
-	/**
84
-	 * @param string $class
85
-	 * @return $this
86
-	 */
87
-	public function setStorageClass($class) {
88
-		$this->storageClass = $class;
89
-		return $this;
90
-	}
91
-
92
-	/**
93
-	 * @return array
94
-	 */
95
-	public function getAuthSchemes() {
96
-		if (empty($this->authSchemes)) {
97
-			return [AuthMechanism::SCHEME_NULL => true];
98
-		}
99
-		return $this->authSchemes;
100
-	}
101
-
102
-	/**
103
-	 * @param string $scheme
104
-	 * @return self
105
-	 */
106
-	public function addAuthScheme($scheme) {
107
-		$this->authSchemes[$scheme] = true;
108
-		return $this;
109
-	}
110
-
111
-	/**
112
-	 * @param array $parameters storage parameters, for dynamic mechanism selection
113
-	 * @return AuthMechanism
114
-	 */
115
-	public function getLegacyAuthMechanism(array $parameters = []) {
116
-		if (is_callable($this->legacyAuthMechanism)) {
117
-			return call_user_func($this->legacyAuthMechanism, $parameters);
118
-		}
119
-		return $this->legacyAuthMechanism;
120
-	}
121
-
122
-	/**
123
-	 * @param AuthMechanism $authMechanism
124
-	 * @return self
125
-	 */
126
-	public function setLegacyAuthMechanism(AuthMechanism $authMechanism) {
127
-		$this->legacyAuthMechanism = $authMechanism;
128
-		return $this;
129
-	}
130
-
131
-	/**
132
-	 * @param callable $callback dynamic auth mechanism selection
133
-	 * @return self
134
-	 */
135
-	public function setLegacyAuthMechanismCallback(callable $callback) {
136
-		$this->legacyAuthMechanism = $callback;
137
-	}
138
-
139
-	/**
140
-	 * Serialize into JSON for client-side JS
141
-	 *
142
-	 * @return array
143
-	 */
144
-	public function jsonSerialize() {
145
-		$data = $this->jsonSerializeDefinition();
146
-		$data += $this->jsonSerializeIdentifier();
147
-
148
-		$data['backend'] = $data['name']; // legacy compat
149
-		$data['priority'] = $this->getPriority();
150
-		$data['authSchemes'] = $this->getAuthSchemes();
151
-
152
-		return $data;
153
-	}
154
-
155
-	/**
156
-	 * Check if parameters are satisfied in a StorageConfig
157
-	 *
158
-	 * @param StorageConfig $storage
159
-	 * @return bool
160
-	 */
161
-	public function validateStorage(StorageConfig $storage) {
162
-		return $this->validateStorageDefinition($storage);
163
-	}
60
+    use VisibilityTrait;
61
+    use FrontendDefinitionTrait;
62
+    use PriorityTrait;
63
+    use DependencyTrait;
64
+    use StorageModifierTrait;
65
+    use IdentifierTrait;
66
+
67
+    /** @var string storage class */
68
+    private $storageClass;
69
+
70
+    /** @var array 'scheme' => true, supported authentication schemes */
71
+    private $authSchemes = [];
72
+
73
+    /** @var AuthMechanism|callable authentication mechanism fallback */
74
+    private $legacyAuthMechanism;
75
+
76
+    /**
77
+     * @return string
78
+     */
79
+    public function getStorageClass() {
80
+        return $this->storageClass;
81
+    }
82
+
83
+    /**
84
+     * @param string $class
85
+     * @return $this
86
+     */
87
+    public function setStorageClass($class) {
88
+        $this->storageClass = $class;
89
+        return $this;
90
+    }
91
+
92
+    /**
93
+     * @return array
94
+     */
95
+    public function getAuthSchemes() {
96
+        if (empty($this->authSchemes)) {
97
+            return [AuthMechanism::SCHEME_NULL => true];
98
+        }
99
+        return $this->authSchemes;
100
+    }
101
+
102
+    /**
103
+     * @param string $scheme
104
+     * @return self
105
+     */
106
+    public function addAuthScheme($scheme) {
107
+        $this->authSchemes[$scheme] = true;
108
+        return $this;
109
+    }
110
+
111
+    /**
112
+     * @param array $parameters storage parameters, for dynamic mechanism selection
113
+     * @return AuthMechanism
114
+     */
115
+    public function getLegacyAuthMechanism(array $parameters = []) {
116
+        if (is_callable($this->legacyAuthMechanism)) {
117
+            return call_user_func($this->legacyAuthMechanism, $parameters);
118
+        }
119
+        return $this->legacyAuthMechanism;
120
+    }
121
+
122
+    /**
123
+     * @param AuthMechanism $authMechanism
124
+     * @return self
125
+     */
126
+    public function setLegacyAuthMechanism(AuthMechanism $authMechanism) {
127
+        $this->legacyAuthMechanism = $authMechanism;
128
+        return $this;
129
+    }
130
+
131
+    /**
132
+     * @param callable $callback dynamic auth mechanism selection
133
+     * @return self
134
+     */
135
+    public function setLegacyAuthMechanismCallback(callable $callback) {
136
+        $this->legacyAuthMechanism = $callback;
137
+    }
138
+
139
+    /**
140
+     * Serialize into JSON for client-side JS
141
+     *
142
+     * @return array
143
+     */
144
+    public function jsonSerialize() {
145
+        $data = $this->jsonSerializeDefinition();
146
+        $data += $this->jsonSerializeIdentifier();
147
+
148
+        $data['backend'] = $data['name']; // legacy compat
149
+        $data['priority'] = $this->getPriority();
150
+        $data['authSchemes'] = $this->getAuthSchemes();
151
+
152
+        return $data;
153
+    }
154
+
155
+    /**
156
+     * Check if parameters are satisfied in a StorageConfig
157
+     *
158
+     * @param StorageConfig $storage
159
+     * @return bool
160
+     */
161
+    public function validateStorage(StorageConfig $storage) {
162
+        return $this->validateStorageDefinition($storage);
163
+    }
164 164
 
165 165
 }
166 166
 
Please login to merge, or discard this patch.
apps/files_external/lib/Lib/FrontendDefinitionTrait.php 1 patch
Indentation   +124 added lines, -124 removed lines patch added patch discarded remove patch
@@ -31,129 +31,129 @@
 block discarded – undo
31 31
  */
32 32
 trait FrontendDefinitionTrait {
33 33
 
34
-	/** @var string human-readable mechanism name */
35
-	private $text;
36
-
37
-	/** @var DefinitionParameter[] parameters for mechanism */
38
-	private $parameters = [];
39
-
40
-	/** @var string[] custom JS */
41
-	private $customJs = [];
42
-
43
-	/**
44
-	 * @return string
45
-	 */
46
-	public function getText() {
47
-		return $this->text;
48
-	}
49
-
50
-	/**
51
-	 * @param string $text
52
-	 * @return $this
53
-	 */
54
-	public function setText($text) {
55
-		$this->text = $text;
56
-		return $this;
57
-	}
58
-
59
-	/**
60
-	 * @param FrontendDefinitionTrait $a
61
-	 * @param FrontendDefinitionTrait $b
62
-	 * @return int
63
-	 */
64
-	public static function lexicalCompare(FrontendDefinitionTrait $a, FrontendDefinitionTrait $b) {
65
-		return strcmp($a->getText(), $b->getText());
66
-	}
67
-
68
-	/**
69
-	 * @return DefinitionParameter[]
70
-	 */
71
-	public function getParameters() {
72
-		return $this->parameters;
73
-	}
74
-
75
-	/**
76
-	 * @param DefinitionParameter[] $parameters
77
-	 * @return self
78
-	 */
79
-	public function addParameters(array $parameters) {
80
-		foreach ($parameters as $parameter) {
81
-			$this->addParameter($parameter);
82
-		}
83
-		return $this;
84
-	}
85
-
86
-	/**
87
-	 * @param DefinitionParameter $parameter
88
-	 * @return self
89
-	 */
90
-	public function addParameter(DefinitionParameter $parameter) {
91
-		$this->parameters[$parameter->getName()] = $parameter;
92
-		return $this;
93
-	}
94
-
95
-	/**
96
-	 * @return string[]
97
-	 */
98
-	public function getCustomJs() {
99
-		return $this->customJs;
100
-	}
101
-
102
-	/**
103
-	 * @param string $custom
104
-	 * @return self
105
-	 */
106
-	public function addCustomJs($custom) {
107
-		$this->customJs[] = $custom;
108
-		return $this;
109
-	}
110
-
111
-	/**
112
-	 * @param string $custom
113
-	 * @return self
114
-	 * @deprecated 9.1.0, use addCustomJs() instead
115
-	 */
116
-	public function setCustomJs($custom) {
117
-		$this->customJs = [$custom];
118
-		return $this;
119
-	}
120
-
121
-	/**
122
-	 * Serialize into JSON for client-side JS
123
-	 *
124
-	 * @return array
125
-	 */
126
-	public function jsonSerializeDefinition() {
127
-		$configuration = [];
128
-		foreach ($this->getParameters() as $parameter) {
129
-			$configuration[$parameter->getName()] = $parameter;
130
-		}
131
-
132
-		$data = [
133
-			'name' => $this->getText(),
134
-			'configuration' => $configuration,
135
-			'custom' => $this->getCustomJs(),
136
-		];
137
-		return $data;
138
-	}
139
-
140
-	/**
141
-	 * Check if parameters are satisfied in a StorageConfig
142
-	 *
143
-	 * @param StorageConfig $storage
144
-	 * @return bool
145
-	 */
146
-	public function validateStorageDefinition(StorageConfig $storage) {
147
-		foreach ($this->getParameters() as $name => $parameter) {
148
-			$value = $storage->getBackendOption($name);
149
-			if (!is_null($value) || !$parameter->isOptional()) {
150
-				if (!$parameter->validateValue($value)) {
151
-					return false;
152
-				}
153
-				$storage->setBackendOption($name, $value);
154
-			}
155
-		}
156
-		return true;
157
-	}
34
+    /** @var string human-readable mechanism name */
35
+    private $text;
36
+
37
+    /** @var DefinitionParameter[] parameters for mechanism */
38
+    private $parameters = [];
39
+
40
+    /** @var string[] custom JS */
41
+    private $customJs = [];
42
+
43
+    /**
44
+     * @return string
45
+     */
46
+    public function getText() {
47
+        return $this->text;
48
+    }
49
+
50
+    /**
51
+     * @param string $text
52
+     * @return $this
53
+     */
54
+    public function setText($text) {
55
+        $this->text = $text;
56
+        return $this;
57
+    }
58
+
59
+    /**
60
+     * @param FrontendDefinitionTrait $a
61
+     * @param FrontendDefinitionTrait $b
62
+     * @return int
63
+     */
64
+    public static function lexicalCompare(FrontendDefinitionTrait $a, FrontendDefinitionTrait $b) {
65
+        return strcmp($a->getText(), $b->getText());
66
+    }
67
+
68
+    /**
69
+     * @return DefinitionParameter[]
70
+     */
71
+    public function getParameters() {
72
+        return $this->parameters;
73
+    }
74
+
75
+    /**
76
+     * @param DefinitionParameter[] $parameters
77
+     * @return self
78
+     */
79
+    public function addParameters(array $parameters) {
80
+        foreach ($parameters as $parameter) {
81
+            $this->addParameter($parameter);
82
+        }
83
+        return $this;
84
+    }
85
+
86
+    /**
87
+     * @param DefinitionParameter $parameter
88
+     * @return self
89
+     */
90
+    public function addParameter(DefinitionParameter $parameter) {
91
+        $this->parameters[$parameter->getName()] = $parameter;
92
+        return $this;
93
+    }
94
+
95
+    /**
96
+     * @return string[]
97
+     */
98
+    public function getCustomJs() {
99
+        return $this->customJs;
100
+    }
101
+
102
+    /**
103
+     * @param string $custom
104
+     * @return self
105
+     */
106
+    public function addCustomJs($custom) {
107
+        $this->customJs[] = $custom;
108
+        return $this;
109
+    }
110
+
111
+    /**
112
+     * @param string $custom
113
+     * @return self
114
+     * @deprecated 9.1.0, use addCustomJs() instead
115
+     */
116
+    public function setCustomJs($custom) {
117
+        $this->customJs = [$custom];
118
+        return $this;
119
+    }
120
+
121
+    /**
122
+     * Serialize into JSON for client-side JS
123
+     *
124
+     * @return array
125
+     */
126
+    public function jsonSerializeDefinition() {
127
+        $configuration = [];
128
+        foreach ($this->getParameters() as $parameter) {
129
+            $configuration[$parameter->getName()] = $parameter;
130
+        }
131
+
132
+        $data = [
133
+            'name' => $this->getText(),
134
+            'configuration' => $configuration,
135
+            'custom' => $this->getCustomJs(),
136
+        ];
137
+        return $data;
138
+    }
139
+
140
+    /**
141
+     * Check if parameters are satisfied in a StorageConfig
142
+     *
143
+     * @param StorageConfig $storage
144
+     * @return bool
145
+     */
146
+    public function validateStorageDefinition(StorageConfig $storage) {
147
+        foreach ($this->getParameters() as $name => $parameter) {
148
+            $value = $storage->getBackendOption($name);
149
+            if (!is_null($value) || !$parameter->isOptional()) {
150
+                if (!$parameter->validateValue($value)) {
151
+                    return false;
152
+                }
153
+                $storage->setBackendOption($name, $value);
154
+            }
155
+        }
156
+        return true;
157
+    }
158 158
 
159 159
 }
Please login to merge, or discard this patch.