@@ -32,14 +32,14 @@ |
||
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 | } |
@@ -32,14 +32,14 @@ |
||
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 | } |
@@ -32,14 +32,14 @@ |
||
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 | } |
@@ -50,7 +50,7 @@ |
||
50 | 50 | public function __construct($arguments) { |
51 | 51 | $this->user = $arguments['user']; |
52 | 52 | $datadir = $this->user->getHome(); |
53 | - $this->id = 'home::' . $this->user->getUID(); |
|
53 | + $this->id = 'home::'.$this->user->getUID(); |
|
54 | 54 | |
55 | 55 | parent::__construct(['datadir' => $datadir]); |
56 | 56 | } |
@@ -33,80 +33,80 @@ |
||
33 | 33 | * Specialized version of Local storage for home directory usage |
34 | 34 | */ |
35 | 35 | class Home extends Local implements \OCP\Files\IHomeStorage { |
36 | - /** |
|
37 | - * @var string |
|
38 | - */ |
|
39 | - protected $id; |
|
36 | + /** |
|
37 | + * @var string |
|
38 | + */ |
|
39 | + protected $id; |
|
40 | 40 | |
41 | - /** |
|
42 | - * @var \OC\User\User $user |
|
43 | - */ |
|
44 | - protected $user; |
|
41 | + /** |
|
42 | + * @var \OC\User\User $user |
|
43 | + */ |
|
44 | + protected $user; |
|
45 | 45 | |
46 | - /** |
|
47 | - * Construct a Home storage instance |
|
48 | - * |
|
49 | - * @param array $arguments array with "user" containing the |
|
50 | - * storage owner |
|
51 | - */ |
|
52 | - public function __construct($arguments) { |
|
53 | - $this->user = $arguments['user']; |
|
54 | - $datadir = $this->user->getHome(); |
|
55 | - $this->id = 'home::' . $this->user->getUID(); |
|
46 | + /** |
|
47 | + * Construct a Home storage instance |
|
48 | + * |
|
49 | + * @param array $arguments array with "user" containing the |
|
50 | + * storage owner |
|
51 | + */ |
|
52 | + public function __construct($arguments) { |
|
53 | + $this->user = $arguments['user']; |
|
54 | + $datadir = $this->user->getHome(); |
|
55 | + $this->id = 'home::' . $this->user->getUID(); |
|
56 | 56 | |
57 | - parent::__construct(['datadir' => $datadir]); |
|
58 | - } |
|
57 | + parent::__construct(['datadir' => $datadir]); |
|
58 | + } |
|
59 | 59 | |
60 | - public function getId() { |
|
61 | - return $this->id; |
|
62 | - } |
|
60 | + public function getId() { |
|
61 | + return $this->id; |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * @return \OC\Files\Cache\HomeCache |
|
66 | - */ |
|
67 | - public function getCache($path = '', $storage = null) { |
|
68 | - if (!$storage) { |
|
69 | - $storage = $this; |
|
70 | - } |
|
71 | - if (!isset($this->cache)) { |
|
72 | - $this->cache = new \OC\Files\Cache\HomeCache($storage); |
|
73 | - } |
|
74 | - return $this->cache; |
|
75 | - } |
|
64 | + /** |
|
65 | + * @return \OC\Files\Cache\HomeCache |
|
66 | + */ |
|
67 | + public function getCache($path = '', $storage = null) { |
|
68 | + if (!$storage) { |
|
69 | + $storage = $this; |
|
70 | + } |
|
71 | + if (!isset($this->cache)) { |
|
72 | + $this->cache = new \OC\Files\Cache\HomeCache($storage); |
|
73 | + } |
|
74 | + return $this->cache; |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * get a propagator instance for the cache |
|
79 | - * |
|
80 | - * @param \OC\Files\Storage\Storage (optional) the storage to pass to the watcher |
|
81 | - * @return \OC\Files\Cache\Propagator |
|
82 | - */ |
|
83 | - public function getPropagator($storage = null) { |
|
84 | - if (!$storage) { |
|
85 | - $storage = $this; |
|
86 | - } |
|
87 | - if (!isset($this->propagator)) { |
|
88 | - $this->propagator = new HomePropagator($storage, \OC::$server->getDatabaseConnection()); |
|
89 | - } |
|
90 | - return $this->propagator; |
|
91 | - } |
|
77 | + /** |
|
78 | + * get a propagator instance for the cache |
|
79 | + * |
|
80 | + * @param \OC\Files\Storage\Storage (optional) the storage to pass to the watcher |
|
81 | + * @return \OC\Files\Cache\Propagator |
|
82 | + */ |
|
83 | + public function getPropagator($storage = null) { |
|
84 | + if (!$storage) { |
|
85 | + $storage = $this; |
|
86 | + } |
|
87 | + if (!isset($this->propagator)) { |
|
88 | + $this->propagator = new HomePropagator($storage, \OC::$server->getDatabaseConnection()); |
|
89 | + } |
|
90 | + return $this->propagator; |
|
91 | + } |
|
92 | 92 | |
93 | 93 | |
94 | - /** |
|
95 | - * Returns the owner of this home storage |
|
96 | - * |
|
97 | - * @return \OC\User\User owner of this home storage |
|
98 | - */ |
|
99 | - public function getUser() { |
|
100 | - return $this->user; |
|
101 | - } |
|
94 | + /** |
|
95 | + * Returns the owner of this home storage |
|
96 | + * |
|
97 | + * @return \OC\User\User owner of this home storage |
|
98 | + */ |
|
99 | + public function getUser() { |
|
100 | + return $this->user; |
|
101 | + } |
|
102 | 102 | |
103 | - /** |
|
104 | - * get the owner of a path |
|
105 | - * |
|
106 | - * @param string $path The path to get the owner |
|
107 | - * @return string uid or false |
|
108 | - */ |
|
109 | - public function getOwner($path) { |
|
110 | - return $this->user->getUID(); |
|
111 | - } |
|
103 | + /** |
|
104 | + * get the owner of a path |
|
105 | + * |
|
106 | + * @param string $path The path to get the owner |
|
107 | + * @return string uid or false |
|
108 | + */ |
|
109 | + public function getOwner($path) { |
|
110 | + return $this->user->getUID(); |
|
111 | + } |
|
112 | 112 | } |
@@ -31,33 +31,33 @@ |
||
31 | 31 | |
32 | 32 | class EMailProvider implements IProvider { |
33 | 33 | |
34 | - /** @var IActionFactory */ |
|
35 | - private $actionFactory; |
|
36 | - |
|
37 | - /** @var IURLGenerator */ |
|
38 | - private $urlGenerator; |
|
39 | - |
|
40 | - /** |
|
41 | - * @param IActionFactory $actionFactory |
|
42 | - * @param IURLGenerator $urlGenerator |
|
43 | - */ |
|
44 | - public function __construct(IActionFactory $actionFactory, IURLGenerator $urlGenerator) { |
|
45 | - $this->actionFactory = $actionFactory; |
|
46 | - $this->urlGenerator = $urlGenerator; |
|
47 | - } |
|
48 | - |
|
49 | - /** |
|
50 | - * @param IEntry $entry |
|
51 | - */ |
|
52 | - public function process(IEntry $entry) { |
|
53 | - $iconUrl = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/mail.svg')); |
|
54 | - foreach ($entry->getEMailAddresses() as $address) { |
|
55 | - if (empty($address)) { |
|
56 | - // Skip |
|
57 | - continue; |
|
58 | - } |
|
59 | - $action = $this->actionFactory->newEMailAction($iconUrl, $address, $address); |
|
60 | - $entry->addAction($action); |
|
61 | - } |
|
62 | - } |
|
34 | + /** @var IActionFactory */ |
|
35 | + private $actionFactory; |
|
36 | + |
|
37 | + /** @var IURLGenerator */ |
|
38 | + private $urlGenerator; |
|
39 | + |
|
40 | + /** |
|
41 | + * @param IActionFactory $actionFactory |
|
42 | + * @param IURLGenerator $urlGenerator |
|
43 | + */ |
|
44 | + public function __construct(IActionFactory $actionFactory, IURLGenerator $urlGenerator) { |
|
45 | + $this->actionFactory = $actionFactory; |
|
46 | + $this->urlGenerator = $urlGenerator; |
|
47 | + } |
|
48 | + |
|
49 | + /** |
|
50 | + * @param IEntry $entry |
|
51 | + */ |
|
52 | + public function process(IEntry $entry) { |
|
53 | + $iconUrl = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/mail.svg')); |
|
54 | + foreach ($entry->getEMailAddresses() as $address) { |
|
55 | + if (empty($address)) { |
|
56 | + // Skip |
|
57 | + continue; |
|
58 | + } |
|
59 | + $action = $this->actionFactory->newEMailAction($iconUrl, $address, $address); |
|
60 | + $entry->addAction($action); |
|
61 | + } |
|
62 | + } |
|
63 | 63 | } |
@@ -32,7 +32,7 @@ |
||
32 | 32 | * @package OC\AppFramework\Middleware\Security\Exceptions |
33 | 33 | */ |
34 | 34 | class StrictCookieMissingException extends SecurityException { |
35 | - public function __construct() { |
|
36 | - parent::__construct('Strict Cookie has not been found in request.', Http::STATUS_PRECONDITION_FAILED); |
|
37 | - } |
|
35 | + public function __construct() { |
|
36 | + parent::__construct('Strict Cookie has not been found in request.', Http::STATUS_PRECONDITION_FAILED); |
|
37 | + } |
|
38 | 38 | } |
@@ -29,40 +29,40 @@ |
||
29 | 29 | |
30 | 30 | class FedAuth extends AbstractBasic { |
31 | 31 | |
32 | - /** @var DbHandler */ |
|
33 | - private $db; |
|
32 | + /** @var DbHandler */ |
|
33 | + private $db; |
|
34 | 34 | |
35 | - /** |
|
36 | - * FedAuth constructor. |
|
37 | - * |
|
38 | - * @param DbHandler $db |
|
39 | - */ |
|
40 | - public function __construct(DbHandler $db) { |
|
41 | - $this->db = $db; |
|
42 | - $this->principalPrefix = 'principals/system/'; |
|
35 | + /** |
|
36 | + * FedAuth constructor. |
|
37 | + * |
|
38 | + * @param DbHandler $db |
|
39 | + */ |
|
40 | + public function __construct(DbHandler $db) { |
|
41 | + $this->db = $db; |
|
42 | + $this->principalPrefix = 'principals/system/'; |
|
43 | 43 | |
44 | - // setup realm |
|
45 | - $defaults = new \OCP\Defaults(); |
|
46 | - $this->realm = $defaults->getName(); |
|
47 | - } |
|
44 | + // setup realm |
|
45 | + $defaults = new \OCP\Defaults(); |
|
46 | + $this->realm = $defaults->getName(); |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * Validates a username and password |
|
51 | - * |
|
52 | - * This method should return true or false depending on if login |
|
53 | - * succeeded. |
|
54 | - * |
|
55 | - * @param string $username |
|
56 | - * @param string $password |
|
57 | - * @return bool |
|
58 | - */ |
|
59 | - protected function validateUserPass($username, $password) { |
|
60 | - return $this->db->auth($username, $password); |
|
61 | - } |
|
49 | + /** |
|
50 | + * Validates a username and password |
|
51 | + * |
|
52 | + * This method should return true or false depending on if login |
|
53 | + * succeeded. |
|
54 | + * |
|
55 | + * @param string $username |
|
56 | + * @param string $password |
|
57 | + * @return bool |
|
58 | + */ |
|
59 | + protected function validateUserPass($username, $password) { |
|
60 | + return $this->db->auth($username, $password); |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * @inheritdoc |
|
65 | - */ |
|
66 | - public function challenge(RequestInterface $request, ResponseInterface $response) { |
|
67 | - } |
|
63 | + /** |
|
64 | + * @inheritdoc |
|
65 | + */ |
|
66 | + public function challenge(RequestInterface $request, ResponseInterface $response) { |
|
67 | + } |
|
68 | 68 | } |
@@ -61,8 +61,7 @@ |
||
61 | 61 | $fn = $this->l10n->getPluralFormFunction(); |
62 | 62 | $id = $fn($this->count); |
63 | 63 | $text = $translations[$this->text][$id]; |
64 | - } |
|
65 | - else{ |
|
64 | + } else{ |
|
66 | 65 | $text = $translations[$this->text]; |
67 | 66 | } |
68 | 67 | } |
@@ -29,59 +29,59 @@ |
||
29 | 29 | namespace OC\L10N; |
30 | 30 | |
31 | 31 | class L10NString implements \JsonSerializable { |
32 | - /** @var \OC\L10N\L10N */ |
|
33 | - protected $l10n; |
|
32 | + /** @var \OC\L10N\L10N */ |
|
33 | + protected $l10n; |
|
34 | 34 | |
35 | - /** @var string */ |
|
36 | - protected $text; |
|
35 | + /** @var string */ |
|
36 | + protected $text; |
|
37 | 37 | |
38 | - /** @var array */ |
|
39 | - protected $parameters; |
|
38 | + /** @var array */ |
|
39 | + protected $parameters; |
|
40 | 40 | |
41 | - /** @var integer */ |
|
42 | - protected $count; |
|
41 | + /** @var integer */ |
|
42 | + protected $count; |
|
43 | 43 | |
44 | - /** |
|
45 | - * @param \OC\L10N\L10N $l10n |
|
46 | - * @param string|string[] $text |
|
47 | - * @param array $parameters |
|
48 | - * @param int $count |
|
49 | - */ |
|
50 | - public function __construct(\OC\L10N\L10N $l10n, $text, $parameters, $count = 1) { |
|
51 | - $this->l10n = $l10n; |
|
52 | - $this->text = $text; |
|
53 | - $this->parameters = $parameters; |
|
54 | - $this->count = $count; |
|
55 | - } |
|
44 | + /** |
|
45 | + * @param \OC\L10N\L10N $l10n |
|
46 | + * @param string|string[] $text |
|
47 | + * @param array $parameters |
|
48 | + * @param int $count |
|
49 | + */ |
|
50 | + public function __construct(\OC\L10N\L10N $l10n, $text, $parameters, $count = 1) { |
|
51 | + $this->l10n = $l10n; |
|
52 | + $this->text = $text; |
|
53 | + $this->parameters = $parameters; |
|
54 | + $this->count = $count; |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * @return string |
|
59 | - */ |
|
60 | - public function __toString() { |
|
61 | - $translations = $this->l10n->getTranslations(); |
|
57 | + /** |
|
58 | + * @return string |
|
59 | + */ |
|
60 | + public function __toString() { |
|
61 | + $translations = $this->l10n->getTranslations(); |
|
62 | 62 | |
63 | - $text = $this->text; |
|
64 | - if(array_key_exists($this->text, $translations)) { |
|
65 | - if(is_array($translations[$this->text])) { |
|
66 | - $fn = $this->l10n->getPluralFormFunction(); |
|
67 | - $id = $fn($this->count); |
|
68 | - $text = $translations[$this->text][$id]; |
|
69 | - } |
|
70 | - else{ |
|
71 | - $text = $translations[$this->text]; |
|
72 | - } |
|
73 | - } |
|
63 | + $text = $this->text; |
|
64 | + if(array_key_exists($this->text, $translations)) { |
|
65 | + if(is_array($translations[$this->text])) { |
|
66 | + $fn = $this->l10n->getPluralFormFunction(); |
|
67 | + $id = $fn($this->count); |
|
68 | + $text = $translations[$this->text][$id]; |
|
69 | + } |
|
70 | + else{ |
|
71 | + $text = $translations[$this->text]; |
|
72 | + } |
|
73 | + } |
|
74 | 74 | |
75 | - // Replace %n first (won't interfere with vsprintf) |
|
76 | - $text = str_replace('%n', (string)$this->count, $text); |
|
77 | - return vsprintf($text, $this->parameters); |
|
78 | - } |
|
75 | + // Replace %n first (won't interfere with vsprintf) |
|
76 | + $text = str_replace('%n', (string)$this->count, $text); |
|
77 | + return vsprintf($text, $this->parameters); |
|
78 | + } |
|
79 | 79 | |
80 | 80 | |
81 | - /** |
|
82 | - * @return string |
|
83 | - */ |
|
84 | - public function jsonSerialize() { |
|
85 | - return $this->__toString(); |
|
86 | - } |
|
81 | + /** |
|
82 | + * @return string |
|
83 | + */ |
|
84 | + public function jsonSerialize() { |
|
85 | + return $this->__toString(); |
|
86 | + } |
|
87 | 87 | } |
@@ -56,19 +56,19 @@ |
||
56 | 56 | $translations = $this->l10n->getTranslations(); |
57 | 57 | |
58 | 58 | $text = $this->text; |
59 | - if(array_key_exists($this->text, $translations)) { |
|
60 | - if(is_array($translations[$this->text])) { |
|
59 | + if (array_key_exists($this->text, $translations)) { |
|
60 | + if (is_array($translations[$this->text])) { |
|
61 | 61 | $fn = $this->l10n->getPluralFormFunction(); |
62 | 62 | $id = $fn($this->count); |
63 | 63 | $text = $translations[$this->text][$id]; |
64 | 64 | } |
65 | - else{ |
|
65 | + else { |
|
66 | 66 | $text = $translations[$this->text]; |
67 | 67 | } |
68 | 68 | } |
69 | 69 | |
70 | 70 | // Replace %n first (won't interfere with vsprintf) |
71 | - $text = str_replace('%n', (string)$this->count, $text); |
|
71 | + $text = str_replace('%n', (string) $this->count, $text); |
|
72 | 72 | return vsprintf($text, $this->parameters); |
73 | 73 | } |
74 | 74 |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | public function castColumn($column, $type) { |
148 | 148 | if ($type === IQueryBuilder::PARAM_STR) { |
149 | 149 | $column = $this->helper->quoteColumnName($column); |
150 | - return new QueryFunction('to_char(' . $column . ')'); |
|
150 | + return new QueryFunction('to_char('.$column.')'); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | return parent::castColumn($column, $type); |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * @inheritdoc |
158 | 158 | */ |
159 | 159 | public function like($x, $y, $type = null) { |
160 | - return parent::like($x, $y, $type) . " ESCAPE '\\'"; |
|
160 | + return parent::like($x, $y, $type)." ESCAPE '\\'"; |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
@@ -166,6 +166,6 @@ discard block |
||
166 | 166 | public function iLike($x, $y, $type = null) { |
167 | 167 | $x = $this->helper->quoteColumnName($x); |
168 | 168 | $y = $this->helper->quoteColumnName($y); |
169 | - return new QueryFunction('REGEXP_LIKE(' . $x . ', \'^\' || REPLACE(REPLACE(' . $y . ', \'%\', \'.*\'), \'_\', \'.\') || \'$\', \'i\')'); |
|
169 | + return new QueryFunction('REGEXP_LIKE('.$x.', \'^\' || REPLACE(REPLACE('.$y.', \'%\', \'.*\'), \'_\', \'.\') || \'$\', \'i\')'); |
|
170 | 170 | } |
171 | 171 | } |
@@ -33,161 +33,161 @@ |
||
33 | 33 | |
34 | 34 | class OCIExpressionBuilder extends ExpressionBuilder { |
35 | 35 | |
36 | - /** |
|
37 | - * @param mixed $column |
|
38 | - * @param mixed|null $type |
|
39 | - * @return array|IQueryFunction|string |
|
40 | - */ |
|
41 | - protected function prepareColumn($column, $type) { |
|
42 | - if ($type === IQueryBuilder::PARAM_STR && !is_array($column) && !($column instanceof IParameter) && !($column instanceof ILiteral)) { |
|
43 | - $column = $this->castColumn($column, $type); |
|
44 | - } else { |
|
45 | - $column = $this->helper->quoteColumnNames($column); |
|
46 | - } |
|
47 | - return $column; |
|
48 | - } |
|
49 | - |
|
50 | - /** |
|
51 | - * @inheritdoc |
|
52 | - */ |
|
53 | - public function comparison($x, $operator, $y, $type = null) { |
|
54 | - $x = $this->prepareColumn($x, $type); |
|
55 | - $y = $this->prepareColumn($y, $type); |
|
56 | - |
|
57 | - return $this->expressionBuilder->comparison($x, $operator, $y); |
|
58 | - } |
|
59 | - |
|
60 | - /** |
|
61 | - * @inheritdoc |
|
62 | - */ |
|
63 | - public function eq($x, $y, $type = null) { |
|
64 | - $x = $this->prepareColumn($x, $type); |
|
65 | - $y = $this->prepareColumn($y, $type); |
|
66 | - |
|
67 | - return $this->expressionBuilder->eq($x, $y); |
|
68 | - } |
|
69 | - |
|
70 | - /** |
|
71 | - * @inheritdoc |
|
72 | - */ |
|
73 | - public function neq($x, $y, $type = null) { |
|
74 | - $x = $this->prepareColumn($x, $type); |
|
75 | - $y = $this->prepareColumn($y, $type); |
|
76 | - |
|
77 | - return $this->expressionBuilder->neq($x, $y); |
|
78 | - } |
|
79 | - |
|
80 | - /** |
|
81 | - * @inheritdoc |
|
82 | - */ |
|
83 | - public function lt($x, $y, $type = null) { |
|
84 | - $x = $this->prepareColumn($x, $type); |
|
85 | - $y = $this->prepareColumn($y, $type); |
|
86 | - |
|
87 | - return $this->expressionBuilder->lt($x, $y); |
|
88 | - } |
|
89 | - |
|
90 | - /** |
|
91 | - * @inheritdoc |
|
92 | - */ |
|
93 | - public function lte($x, $y, $type = null) { |
|
94 | - $x = $this->prepareColumn($x, $type); |
|
95 | - $y = $this->prepareColumn($y, $type); |
|
96 | - |
|
97 | - return $this->expressionBuilder->lte($x, $y); |
|
98 | - } |
|
99 | - |
|
100 | - /** |
|
101 | - * @inheritdoc |
|
102 | - */ |
|
103 | - public function gt($x, $y, $type = null) { |
|
104 | - $x = $this->prepareColumn($x, $type); |
|
105 | - $y = $this->prepareColumn($y, $type); |
|
106 | - |
|
107 | - return $this->expressionBuilder->gt($x, $y); |
|
108 | - } |
|
109 | - |
|
110 | - /** |
|
111 | - * @inheritdoc |
|
112 | - */ |
|
113 | - public function gte($x, $y, $type = null) { |
|
114 | - $x = $this->prepareColumn($x, $type); |
|
115 | - $y = $this->prepareColumn($y, $type); |
|
116 | - |
|
117 | - return $this->expressionBuilder->gte($x, $y); |
|
118 | - } |
|
119 | - |
|
120 | - /** |
|
121 | - * @inheritdoc |
|
122 | - */ |
|
123 | - public function in($x, $y, $type = null) { |
|
124 | - $x = $this->prepareColumn($x, $type); |
|
125 | - $y = $this->prepareColumn($y, $type); |
|
126 | - |
|
127 | - return $this->expressionBuilder->in($x, $y); |
|
128 | - } |
|
129 | - |
|
130 | - /** |
|
131 | - * @inheritdoc |
|
132 | - */ |
|
133 | - public function notIn($x, $y, $type = null) { |
|
134 | - $x = $this->prepareColumn($x, $type); |
|
135 | - $y = $this->prepareColumn($y, $type); |
|
136 | - |
|
137 | - return $this->expressionBuilder->notIn($x, $y); |
|
138 | - } |
|
139 | - |
|
140 | - /** |
|
141 | - * Creates a $x = '' statement, because Oracle needs a different check |
|
142 | - * |
|
143 | - * @param string $x The field in string format to be inspected by the comparison. |
|
144 | - * @return string |
|
145 | - * @since 13.0.0 |
|
146 | - */ |
|
147 | - public function emptyString($x) { |
|
148 | - return $this->isNull($x); |
|
149 | - } |
|
150 | - |
|
151 | - /** |
|
152 | - * Creates a `$x <> ''` statement, because Oracle needs a different check |
|
153 | - * |
|
154 | - * @param string $x The field in string format to be inspected by the comparison. |
|
155 | - * @return string |
|
156 | - * @since 13.0.0 |
|
157 | - */ |
|
158 | - public function nonEmptyString($x) { |
|
159 | - return $this->isNotNull($x); |
|
160 | - } |
|
161 | - |
|
162 | - /** |
|
163 | - * Returns a IQueryFunction that casts the column to the given type |
|
164 | - * |
|
165 | - * @param string $column |
|
166 | - * @param mixed $type One of IQueryBuilder::PARAM_* |
|
167 | - * @return IQueryFunction |
|
168 | - */ |
|
169 | - public function castColumn($column, $type) { |
|
170 | - if ($type === IQueryBuilder::PARAM_STR) { |
|
171 | - $column = $this->helper->quoteColumnName($column); |
|
172 | - return new QueryFunction('to_char(' . $column . ')'); |
|
173 | - } |
|
174 | - |
|
175 | - return parent::castColumn($column, $type); |
|
176 | - } |
|
177 | - |
|
178 | - /** |
|
179 | - * @inheritdoc |
|
180 | - */ |
|
181 | - public function like($x, $y, $type = null) { |
|
182 | - return parent::like($x, $y, $type) . " ESCAPE '\\'"; |
|
183 | - } |
|
184 | - |
|
185 | - /** |
|
186 | - * @inheritdoc |
|
187 | - */ |
|
188 | - public function iLike($x, $y, $type = null) { |
|
189 | - $x = $this->helper->quoteColumnName($x); |
|
190 | - $y = $this->helper->quoteColumnName($y); |
|
191 | - return new QueryFunction('REGEXP_LIKE(' . $x . ', \'^\' || REPLACE(REPLACE(' . $y . ', \'%\', \'.*\'), \'_\', \'.\') || \'$\', \'i\')'); |
|
192 | - } |
|
36 | + /** |
|
37 | + * @param mixed $column |
|
38 | + * @param mixed|null $type |
|
39 | + * @return array|IQueryFunction|string |
|
40 | + */ |
|
41 | + protected function prepareColumn($column, $type) { |
|
42 | + if ($type === IQueryBuilder::PARAM_STR && !is_array($column) && !($column instanceof IParameter) && !($column instanceof ILiteral)) { |
|
43 | + $column = $this->castColumn($column, $type); |
|
44 | + } else { |
|
45 | + $column = $this->helper->quoteColumnNames($column); |
|
46 | + } |
|
47 | + return $column; |
|
48 | + } |
|
49 | + |
|
50 | + /** |
|
51 | + * @inheritdoc |
|
52 | + */ |
|
53 | + public function comparison($x, $operator, $y, $type = null) { |
|
54 | + $x = $this->prepareColumn($x, $type); |
|
55 | + $y = $this->prepareColumn($y, $type); |
|
56 | + |
|
57 | + return $this->expressionBuilder->comparison($x, $operator, $y); |
|
58 | + } |
|
59 | + |
|
60 | + /** |
|
61 | + * @inheritdoc |
|
62 | + */ |
|
63 | + public function eq($x, $y, $type = null) { |
|
64 | + $x = $this->prepareColumn($x, $type); |
|
65 | + $y = $this->prepareColumn($y, $type); |
|
66 | + |
|
67 | + return $this->expressionBuilder->eq($x, $y); |
|
68 | + } |
|
69 | + |
|
70 | + /** |
|
71 | + * @inheritdoc |
|
72 | + */ |
|
73 | + public function neq($x, $y, $type = null) { |
|
74 | + $x = $this->prepareColumn($x, $type); |
|
75 | + $y = $this->prepareColumn($y, $type); |
|
76 | + |
|
77 | + return $this->expressionBuilder->neq($x, $y); |
|
78 | + } |
|
79 | + |
|
80 | + /** |
|
81 | + * @inheritdoc |
|
82 | + */ |
|
83 | + public function lt($x, $y, $type = null) { |
|
84 | + $x = $this->prepareColumn($x, $type); |
|
85 | + $y = $this->prepareColumn($y, $type); |
|
86 | + |
|
87 | + return $this->expressionBuilder->lt($x, $y); |
|
88 | + } |
|
89 | + |
|
90 | + /** |
|
91 | + * @inheritdoc |
|
92 | + */ |
|
93 | + public function lte($x, $y, $type = null) { |
|
94 | + $x = $this->prepareColumn($x, $type); |
|
95 | + $y = $this->prepareColumn($y, $type); |
|
96 | + |
|
97 | + return $this->expressionBuilder->lte($x, $y); |
|
98 | + } |
|
99 | + |
|
100 | + /** |
|
101 | + * @inheritdoc |
|
102 | + */ |
|
103 | + public function gt($x, $y, $type = null) { |
|
104 | + $x = $this->prepareColumn($x, $type); |
|
105 | + $y = $this->prepareColumn($y, $type); |
|
106 | + |
|
107 | + return $this->expressionBuilder->gt($x, $y); |
|
108 | + } |
|
109 | + |
|
110 | + /** |
|
111 | + * @inheritdoc |
|
112 | + */ |
|
113 | + public function gte($x, $y, $type = null) { |
|
114 | + $x = $this->prepareColumn($x, $type); |
|
115 | + $y = $this->prepareColumn($y, $type); |
|
116 | + |
|
117 | + return $this->expressionBuilder->gte($x, $y); |
|
118 | + } |
|
119 | + |
|
120 | + /** |
|
121 | + * @inheritdoc |
|
122 | + */ |
|
123 | + public function in($x, $y, $type = null) { |
|
124 | + $x = $this->prepareColumn($x, $type); |
|
125 | + $y = $this->prepareColumn($y, $type); |
|
126 | + |
|
127 | + return $this->expressionBuilder->in($x, $y); |
|
128 | + } |
|
129 | + |
|
130 | + /** |
|
131 | + * @inheritdoc |
|
132 | + */ |
|
133 | + public function notIn($x, $y, $type = null) { |
|
134 | + $x = $this->prepareColumn($x, $type); |
|
135 | + $y = $this->prepareColumn($y, $type); |
|
136 | + |
|
137 | + return $this->expressionBuilder->notIn($x, $y); |
|
138 | + } |
|
139 | + |
|
140 | + /** |
|
141 | + * Creates a $x = '' statement, because Oracle needs a different check |
|
142 | + * |
|
143 | + * @param string $x The field in string format to be inspected by the comparison. |
|
144 | + * @return string |
|
145 | + * @since 13.0.0 |
|
146 | + */ |
|
147 | + public function emptyString($x) { |
|
148 | + return $this->isNull($x); |
|
149 | + } |
|
150 | + |
|
151 | + /** |
|
152 | + * Creates a `$x <> ''` statement, because Oracle needs a different check |
|
153 | + * |
|
154 | + * @param string $x The field in string format to be inspected by the comparison. |
|
155 | + * @return string |
|
156 | + * @since 13.0.0 |
|
157 | + */ |
|
158 | + public function nonEmptyString($x) { |
|
159 | + return $this->isNotNull($x); |
|
160 | + } |
|
161 | + |
|
162 | + /** |
|
163 | + * Returns a IQueryFunction that casts the column to the given type |
|
164 | + * |
|
165 | + * @param string $column |
|
166 | + * @param mixed $type One of IQueryBuilder::PARAM_* |
|
167 | + * @return IQueryFunction |
|
168 | + */ |
|
169 | + public function castColumn($column, $type) { |
|
170 | + if ($type === IQueryBuilder::PARAM_STR) { |
|
171 | + $column = $this->helper->quoteColumnName($column); |
|
172 | + return new QueryFunction('to_char(' . $column . ')'); |
|
173 | + } |
|
174 | + |
|
175 | + return parent::castColumn($column, $type); |
|
176 | + } |
|
177 | + |
|
178 | + /** |
|
179 | + * @inheritdoc |
|
180 | + */ |
|
181 | + public function like($x, $y, $type = null) { |
|
182 | + return parent::like($x, $y, $type) . " ESCAPE '\\'"; |
|
183 | + } |
|
184 | + |
|
185 | + /** |
|
186 | + * @inheritdoc |
|
187 | + */ |
|
188 | + public function iLike($x, $y, $type = null) { |
|
189 | + $x = $this->helper->quoteColumnName($x); |
|
190 | + $y = $this->helper->quoteColumnName($y); |
|
191 | + return new QueryFunction('REGEXP_LIKE(' . $x . ', \'^\' || REPLACE(REPLACE(' . $y . ', \'%\', \'.*\'), \'_\', \'.\') || \'$\', \'i\')'); |
|
192 | + } |
|
193 | 193 | } |