@@ -28,60 +28,60 @@ |
||
| 28 | 28 | use OCP\DB\QueryBuilder\IFunctionBuilder; |
| 29 | 29 | |
| 30 | 30 | class FunctionBuilder implements IFunctionBuilder { |
| 31 | - /** @var QuoteHelper */ |
|
| 32 | - protected $helper; |
|
| 31 | + /** @var QuoteHelper */ |
|
| 32 | + protected $helper; |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * ExpressionBuilder constructor. |
|
| 36 | - * |
|
| 37 | - * @param QuoteHelper $helper |
|
| 38 | - */ |
|
| 39 | - public function __construct(QuoteHelper $helper) { |
|
| 40 | - $this->helper = $helper; |
|
| 41 | - } |
|
| 34 | + /** |
|
| 35 | + * ExpressionBuilder constructor. |
|
| 36 | + * |
|
| 37 | + * @param QuoteHelper $helper |
|
| 38 | + */ |
|
| 39 | + public function __construct(QuoteHelper $helper) { |
|
| 40 | + $this->helper = $helper; |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - public function md5($input) { |
|
| 44 | - return new QueryFunction('MD5(' . $this->helper->quoteColumnName($input) . ')'); |
|
| 45 | - } |
|
| 43 | + public function md5($input) { |
|
| 44 | + return new QueryFunction('MD5(' . $this->helper->quoteColumnName($input) . ')'); |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - public function concat($x, $y) { |
|
| 48 | - return new QueryFunction('CONCAT(' . $this->helper->quoteColumnName($x) . ', ' . $this->helper->quoteColumnName($y) . ')'); |
|
| 49 | - } |
|
| 47 | + public function concat($x, $y) { |
|
| 48 | + return new QueryFunction('CONCAT(' . $this->helper->quoteColumnName($x) . ', ' . $this->helper->quoteColumnName($y) . ')'); |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - public function substring($input, $start, $length = null) { |
|
| 52 | - if ($length) { |
|
| 53 | - return new QueryFunction('SUBSTR(' . $this->helper->quoteColumnName($input) . ', ' . $this->helper->quoteColumnName($start) . ', ' . $this->helper->quoteColumnName($length) . ')'); |
|
| 54 | - } else { |
|
| 55 | - return new QueryFunction('SUBSTR(' . $this->helper->quoteColumnName($input) . ', ' . $this->helper->quoteColumnName($start) . ')'); |
|
| 56 | - } |
|
| 57 | - } |
|
| 51 | + public function substring($input, $start, $length = null) { |
|
| 52 | + if ($length) { |
|
| 53 | + return new QueryFunction('SUBSTR(' . $this->helper->quoteColumnName($input) . ', ' . $this->helper->quoteColumnName($start) . ', ' . $this->helper->quoteColumnName($length) . ')'); |
|
| 54 | + } else { |
|
| 55 | + return new QueryFunction('SUBSTR(' . $this->helper->quoteColumnName($input) . ', ' . $this->helper->quoteColumnName($start) . ')'); |
|
| 56 | + } |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - public function sum($field) { |
|
| 60 | - return new QueryFunction('SUM(' . $this->helper->quoteColumnName($field) . ')'); |
|
| 61 | - } |
|
| 59 | + public function sum($field) { |
|
| 60 | + return new QueryFunction('SUM(' . $this->helper->quoteColumnName($field) . ')'); |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - public function lower($field) { |
|
| 64 | - return new QueryFunction('LOWER(' . $this->helper->quoteColumnName($field) . ')'); |
|
| 65 | - } |
|
| 63 | + public function lower($field) { |
|
| 64 | + return new QueryFunction('LOWER(' . $this->helper->quoteColumnName($field) . ')'); |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - public function add($x, $y) { |
|
| 68 | - return new QueryFunction($this->helper->quoteColumnName($x) . ' + ' . $this->helper->quoteColumnName($y)); |
|
| 69 | - } |
|
| 67 | + public function add($x, $y) { |
|
| 68 | + return new QueryFunction($this->helper->quoteColumnName($x) . ' + ' . $this->helper->quoteColumnName($y)); |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - public function subtract($x, $y) { |
|
| 72 | - return new QueryFunction($this->helper->quoteColumnName($x) . ' - ' . $this->helper->quoteColumnName($y)); |
|
| 73 | - } |
|
| 71 | + public function subtract($x, $y) { |
|
| 72 | + return new QueryFunction($this->helper->quoteColumnName($x) . ' - ' . $this->helper->quoteColumnName($y)); |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - public function count($count, $alias = '') { |
|
| 76 | - $alias = $alias ? (' AS ' . $this->helper->quoteColumnName($alias)) : ''; |
|
| 77 | - return new QueryFunction('COUNT(' . $this->helper->quoteColumnName($count) . ')' . $alias); |
|
| 78 | - } |
|
| 75 | + public function count($count, $alias = '') { |
|
| 76 | + $alias = $alias ? (' AS ' . $this->helper->quoteColumnName($alias)) : ''; |
|
| 77 | + return new QueryFunction('COUNT(' . $this->helper->quoteColumnName($count) . ')' . $alias); |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - public function max($field) { |
|
| 81 | - return new QueryFunction('MAX(' . $this->helper->quoteColumnName($field) . ')'); |
|
| 82 | - } |
|
| 80 | + public function max($field) { |
|
| 81 | + return new QueryFunction('MAX(' . $this->helper->quoteColumnName($field) . ')'); |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | - public function min($field) { |
|
| 85 | - return new QueryFunction('MIN(' . $this->helper->quoteColumnName($field) . ')'); |
|
| 86 | - } |
|
| 84 | + public function min($field) { |
|
| 85 | + return new QueryFunction('MIN(' . $this->helper->quoteColumnName($field) . ')'); |
|
| 86 | + } |
|
| 87 | 87 | } |
@@ -41,47 +41,47 @@ |
||
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | public function md5($input) { |
| 44 | - return new QueryFunction('MD5(' . $this->helper->quoteColumnName($input) . ')'); |
|
| 44 | + return new QueryFunction('MD5('.$this->helper->quoteColumnName($input).')'); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | public function concat($x, $y) { |
| 48 | - return new QueryFunction('CONCAT(' . $this->helper->quoteColumnName($x) . ', ' . $this->helper->quoteColumnName($y) . ')'); |
|
| 48 | + return new QueryFunction('CONCAT('.$this->helper->quoteColumnName($x).', '.$this->helper->quoteColumnName($y).')'); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | public function substring($input, $start, $length = null) { |
| 52 | 52 | if ($length) { |
| 53 | - return new QueryFunction('SUBSTR(' . $this->helper->quoteColumnName($input) . ', ' . $this->helper->quoteColumnName($start) . ', ' . $this->helper->quoteColumnName($length) . ')'); |
|
| 53 | + return new QueryFunction('SUBSTR('.$this->helper->quoteColumnName($input).', '.$this->helper->quoteColumnName($start).', '.$this->helper->quoteColumnName($length).')'); |
|
| 54 | 54 | } else { |
| 55 | - return new QueryFunction('SUBSTR(' . $this->helper->quoteColumnName($input) . ', ' . $this->helper->quoteColumnName($start) . ')'); |
|
| 55 | + return new QueryFunction('SUBSTR('.$this->helper->quoteColumnName($input).', '.$this->helper->quoteColumnName($start).')'); |
|
| 56 | 56 | } |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | public function sum($field) { |
| 60 | - return new QueryFunction('SUM(' . $this->helper->quoteColumnName($field) . ')'); |
|
| 60 | + return new QueryFunction('SUM('.$this->helper->quoteColumnName($field).')'); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | public function lower($field) { |
| 64 | - return new QueryFunction('LOWER(' . $this->helper->quoteColumnName($field) . ')'); |
|
| 64 | + return new QueryFunction('LOWER('.$this->helper->quoteColumnName($field).')'); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | public function add($x, $y) { |
| 68 | - return new QueryFunction($this->helper->quoteColumnName($x) . ' + ' . $this->helper->quoteColumnName($y)); |
|
| 68 | + return new QueryFunction($this->helper->quoteColumnName($x).' + '.$this->helper->quoteColumnName($y)); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | public function subtract($x, $y) { |
| 72 | - return new QueryFunction($this->helper->quoteColumnName($x) . ' - ' . $this->helper->quoteColumnName($y)); |
|
| 72 | + return new QueryFunction($this->helper->quoteColumnName($x).' - '.$this->helper->quoteColumnName($y)); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | public function count($count, $alias = '') { |
| 76 | - $alias = $alias ? (' AS ' . $this->helper->quoteColumnName($alias)) : ''; |
|
| 77 | - return new QueryFunction('COUNT(' . $this->helper->quoteColumnName($count) . ')' . $alias); |
|
| 76 | + $alias = $alias ? (' AS '.$this->helper->quoteColumnName($alias)) : ''; |
|
| 77 | + return new QueryFunction('COUNT('.$this->helper->quoteColumnName($count).')'.$alias); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | public function max($field) { |
| 81 | - return new QueryFunction('MAX(' . $this->helper->quoteColumnName($field) . ')'); |
|
| 81 | + return new QueryFunction('MAX('.$this->helper->quoteColumnName($field).')'); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | public function min($field) { |
| 85 | - return new QueryFunction('MIN(' . $this->helper->quoteColumnName($field) . ')'); |
|
| 85 | + return new QueryFunction('MIN('.$this->helper->quoteColumnName($field).')'); |
|
| 86 | 86 | } |
| 87 | 87 | } |
@@ -29,100 +29,100 @@ |
||
| 29 | 29 | * @since 12.0.0 |
| 30 | 30 | */ |
| 31 | 31 | interface IFunctionBuilder { |
| 32 | - /** |
|
| 33 | - * Calculates the MD5 hash of a given input |
|
| 34 | - * |
|
| 35 | - * @param mixed $input The input to be hashed |
|
| 36 | - * |
|
| 37 | - * @return IQueryFunction |
|
| 38 | - * @since 12.0.0 |
|
| 39 | - */ |
|
| 40 | - public function md5($input); |
|
| 32 | + /** |
|
| 33 | + * Calculates the MD5 hash of a given input |
|
| 34 | + * |
|
| 35 | + * @param mixed $input The input to be hashed |
|
| 36 | + * |
|
| 37 | + * @return IQueryFunction |
|
| 38 | + * @since 12.0.0 |
|
| 39 | + */ |
|
| 40 | + public function md5($input); |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * Combines two input strings |
|
| 44 | - * |
|
| 45 | - * @param mixed $x The first input string |
|
| 46 | - * @param mixed $y The seccond input string |
|
| 47 | - * |
|
| 48 | - * @return IQueryFunction |
|
| 49 | - * @since 12.0.0 |
|
| 50 | - */ |
|
| 51 | - public function concat($x, $y); |
|
| 42 | + /** |
|
| 43 | + * Combines two input strings |
|
| 44 | + * |
|
| 45 | + * @param mixed $x The first input string |
|
| 46 | + * @param mixed $y The seccond input string |
|
| 47 | + * |
|
| 48 | + * @return IQueryFunction |
|
| 49 | + * @since 12.0.0 |
|
| 50 | + */ |
|
| 51 | + public function concat($x, $y); |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * Takes a substring from the input string |
|
| 55 | - * |
|
| 56 | - * @param mixed $input The input string |
|
| 57 | - * @param mixed $start The start of the substring, note that counting starts at 1 |
|
| 58 | - * @param mixed $length The length of the substring |
|
| 59 | - * |
|
| 60 | - * @return IQueryFunction |
|
| 61 | - * @since 12.0.0 |
|
| 62 | - */ |
|
| 63 | - public function substring($input, $start, $length = null); |
|
| 53 | + /** |
|
| 54 | + * Takes a substring from the input string |
|
| 55 | + * |
|
| 56 | + * @param mixed $input The input string |
|
| 57 | + * @param mixed $start The start of the substring, note that counting starts at 1 |
|
| 58 | + * @param mixed $length The length of the substring |
|
| 59 | + * |
|
| 60 | + * @return IQueryFunction |
|
| 61 | + * @since 12.0.0 |
|
| 62 | + */ |
|
| 63 | + public function substring($input, $start, $length = null); |
|
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * Takes the sum of all rows in a column |
|
| 67 | - * |
|
| 68 | - * @param mixed $field the column to sum |
|
| 69 | - * |
|
| 70 | - * @return IQueryFunction |
|
| 71 | - * @since 12.0.0 |
|
| 72 | - */ |
|
| 73 | - public function sum($field); |
|
| 65 | + /** |
|
| 66 | + * Takes the sum of all rows in a column |
|
| 67 | + * |
|
| 68 | + * @param mixed $field the column to sum |
|
| 69 | + * |
|
| 70 | + * @return IQueryFunction |
|
| 71 | + * @since 12.0.0 |
|
| 72 | + */ |
|
| 73 | + public function sum($field); |
|
| 74 | 74 | |
| 75 | - /** |
|
| 76 | - * Transforms a string field or value to lower case |
|
| 77 | - * |
|
| 78 | - * @param mixed $field |
|
| 79 | - * @return IQueryFunction |
|
| 80 | - * @since 14.0.0 |
|
| 81 | - */ |
|
| 82 | - public function lower($field); |
|
| 75 | + /** |
|
| 76 | + * Transforms a string field or value to lower case |
|
| 77 | + * |
|
| 78 | + * @param mixed $field |
|
| 79 | + * @return IQueryFunction |
|
| 80 | + * @since 14.0.0 |
|
| 81 | + */ |
|
| 82 | + public function lower($field); |
|
| 83 | 83 | |
| 84 | - /** |
|
| 85 | - * @param mixed $x The first input field or number |
|
| 86 | - * @param mixed $y The second input field or number |
|
| 87 | - * @return IQueryFunction |
|
| 88 | - * @since 14.0.0 |
|
| 89 | - */ |
|
| 90 | - public function add($x, $y); |
|
| 84 | + /** |
|
| 85 | + * @param mixed $x The first input field or number |
|
| 86 | + * @param mixed $y The second input field or number |
|
| 87 | + * @return IQueryFunction |
|
| 88 | + * @since 14.0.0 |
|
| 89 | + */ |
|
| 90 | + public function add($x, $y); |
|
| 91 | 91 | |
| 92 | - /** |
|
| 93 | - * @param mixed $x The first input field or number |
|
| 94 | - * @param mixed $y The second input field or number |
|
| 95 | - * @return IQueryFunction |
|
| 96 | - * @since 14.0.0 |
|
| 97 | - */ |
|
| 98 | - public function subtract($x, $y); |
|
| 92 | + /** |
|
| 93 | + * @param mixed $x The first input field or number |
|
| 94 | + * @param mixed $y The second input field or number |
|
| 95 | + * @return IQueryFunction |
|
| 96 | + * @since 14.0.0 |
|
| 97 | + */ |
|
| 98 | + public function subtract($x, $y); |
|
| 99 | 99 | |
| 100 | - /** |
|
| 101 | - * @param mixed $count The input to be counted |
|
| 102 | - * @param string $alias Alias for the counter |
|
| 103 | - * |
|
| 104 | - * @return IQueryFunction |
|
| 105 | - * @since 14.0.0 |
|
| 106 | - */ |
|
| 107 | - public function count($count, $alias = ''); |
|
| 100 | + /** |
|
| 101 | + * @param mixed $count The input to be counted |
|
| 102 | + * @param string $alias Alias for the counter |
|
| 103 | + * |
|
| 104 | + * @return IQueryFunction |
|
| 105 | + * @since 14.0.0 |
|
| 106 | + */ |
|
| 107 | + public function count($count, $alias = ''); |
|
| 108 | 108 | |
| 109 | - /** |
|
| 110 | - * Takes the maximum of all rows in a column |
|
| 111 | - * |
|
| 112 | - * @param mixed $field the column to maximum |
|
| 113 | - * |
|
| 114 | - * @return IQueryFunction |
|
| 115 | - * @since 18.0.0 |
|
| 116 | - */ |
|
| 117 | - public function max($field); |
|
| 109 | + /** |
|
| 110 | + * Takes the maximum of all rows in a column |
|
| 111 | + * |
|
| 112 | + * @param mixed $field the column to maximum |
|
| 113 | + * |
|
| 114 | + * @return IQueryFunction |
|
| 115 | + * @since 18.0.0 |
|
| 116 | + */ |
|
| 117 | + public function max($field); |
|
| 118 | 118 | |
| 119 | - /** |
|
| 120 | - * Takes the minimum of all rows in a column |
|
| 121 | - * |
|
| 122 | - * @param mixed $field the column to minimum |
|
| 123 | - * |
|
| 124 | - * @return IQueryFunction |
|
| 125 | - * @since 18.0.0 |
|
| 126 | - */ |
|
| 127 | - public function min($field); |
|
| 119 | + /** |
|
| 120 | + * Takes the minimum of all rows in a column |
|
| 121 | + * |
|
| 122 | + * @param mixed $field the column to minimum |
|
| 123 | + * |
|
| 124 | + * @return IQueryFunction |
|
| 125 | + * @since 18.0.0 |
|
| 126 | + */ |
|
| 127 | + public function min($field); |
|
| 128 | 128 | } |