You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
2.3 KiB

3 years ago
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  6. * @author Joas Schilling <coding@schilljs.com>
  7. *
  8. * @license AGPL-3.0
  9. *
  10. * This code is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License, version 3,
  12. * as published by the Free Software Foundation.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License, version 3,
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>
  21. *
  22. */
  23. namespace OC\DB\QueryBuilder;
  24. use OCP\DB\QueryBuilder\ICompositeExpression;
  25. class CompositeExpression implements ICompositeExpression, \Countable {
  26. /** @var \Doctrine\DBAL\Query\Expression\CompositeExpression */
  27. protected $compositeExpression;
  28. /**
  29. * Constructor.
  30. *
  31. * @param \Doctrine\DBAL\Query\Expression\CompositeExpression $compositeExpression
  32. */
  33. public function __construct(\Doctrine\DBAL\Query\Expression\CompositeExpression $compositeExpression) {
  34. $this->compositeExpression = $compositeExpression;
  35. }
  36. /**
  37. * Adds multiple parts to composite expression.
  38. *
  39. * @param array $parts
  40. *
  41. * @return \OCP\DB\QueryBuilder\ICompositeExpression
  42. */
  43. public function addMultiple(array $parts = []) {
  44. $this->compositeExpression->addMultiple($parts);
  45. return $this;
  46. }
  47. /**
  48. * Adds an expression to composite expression.
  49. *
  50. * @param mixed $part
  51. *
  52. * @return \OCP\DB\QueryBuilder\ICompositeExpression
  53. */
  54. public function add($part) {
  55. $this->compositeExpression->add($part);
  56. return $this;
  57. }
  58. /**
  59. * Retrieves the amount of expressions on composite expression.
  60. *
  61. * @return integer
  62. */
  63. public function count() {
  64. return $this->compositeExpression->count();
  65. }
  66. /**
  67. * Returns the type of this composite expression (AND/OR).
  68. *
  69. * @return string
  70. */
  71. public function getType() {
  72. return $this->compositeExpression->getType();
  73. }
  74. /**
  75. * Retrieves the string representation of this composite expression.
  76. *
  77. * @return string
  78. */
  79. public function __toString() {
  80. return (string) $this->compositeExpression;
  81. }
  82. }