Apply PSR-12 code style (#3886)
[GitHub/WoltLab/WCF.git] / wcfsetup / install / files / lib / system / database / util / ConditionBuilder.class.php
index e4d22f01853c5bd5fcff503a55213912800b3165..a2223a998f9dc8fee75e8e17ec248f2dcfe8aa49 100644 (file)
@@ -1,73 +1,83 @@
 <?php
+
 namespace wcf\system\database\util;
 
 /**
  * Builds a sql query 'where' condition.
- * 
- * @author     Marcel Werk
- * @copyright  2001-2019 WoltLab GmbH
- * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package    WoltLabSuite\Core\System\Database\Util
+ *
+ * @author  Marcel Werk
+ * @copyright   2001-2019 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package WoltLabSuite\Core\System\Database\Util
  */
-class ConditionBuilder {
-       /**
-        * must be true to add the 'WHERE' keyword automatically
-        * @var bool
-        */
-       protected $addWhereKeyword = true;
-       
-       /**
-        * string used for concatenating conditions
-        * @var string
-        */
-       protected $concat = '';
-       
-       /**
-        * conditions string
-        * @var string
-        */
-       protected $conditions = '';
-       
-       /**
-        * Creates a new ConditionBuilder object.
-        * 
-        * @param       bool            $addWhereKeyword
-        * @param       string          $concat
-        */
-       public function __construct($addWhereKeyword = true, $concat = 'AND') {
-               $this->addWhereKeyword = $addWhereKeyword;
-               $this->concat = ($concat == 'OR') ? ' OR ' : ' AND ';
-       }
-       
-       /**
-        * Adds a new condition.
-        * 
-        * @param       mixed           $conditions
-        */
-       public function add($conditions) {
-               if (!is_array($conditions)) $conditions = [$conditions];
-               
-               foreach ($conditions as $condition) {
-                       if (!empty($this->conditions)) $this->conditions .= $this->concat;
-                       $this->conditions .= $condition;
-               }
-       }
-       
-       /**
-        * Returns the build condition.
-        * 
-        * @return      string
-        */
-       public function __toString() {
-               return (($this->addWhereKeyword && $this->conditions) ? 'WHERE ' : '').$this->conditions;
-       }
-       
-       /**
-        * Enables / disables the where keyword.
-        * 
-        * @param       bool            $enable
-        */
-       public function enableWhereKeyword($enable = true) {
-               $this->addWhereKeyword = $enable;
-       }
+class ConditionBuilder
+{
+    /**
+     * must be true to add the 'WHERE' keyword automatically
+     * @var bool
+     */
+    protected $addWhereKeyword = true;
+
+    /**
+     * string used for concatenating conditions
+     * @var string
+     */
+    protected $concat = '';
+
+    /**
+     * conditions string
+     * @var string
+     */
+    protected $conditions = '';
+
+    /**
+     * Creates a new ConditionBuilder object.
+     *
+     * @param bool $addWhereKeyword
+     * @param string $concat
+     */
+    public function __construct($addWhereKeyword = true, $concat = 'AND')
+    {
+        $this->addWhereKeyword = $addWhereKeyword;
+        $this->concat = ($concat == 'OR') ? ' OR ' : ' AND ';
+    }
+
+    /**
+     * Adds a new condition.
+     *
+     * @param mixed $conditions
+     */
+    public function add($conditions)
+    {
+        if (!\is_array($conditions)) {
+            $conditions = [$conditions];
+        }
+
+        foreach ($conditions as $condition) {
+            if (!empty($this->conditions)) {
+                $this->conditions .= $this->concat;
+            }
+            $this->conditions .= $condition;
+        }
+    }
+
+    /**
+     * Returns the build condition.
+     *
+     * @return  string
+     */
+    public function __toString()
+    {
+        return (($this->addWhereKeyword && $this->conditions) ? 'WHERE ' : '') . $this->conditions;
+    }
+
+    /**
+     * Enables / disables the where keyword.
+     *
+     * @param bool $enable
+     */
+    public function enableWhereKeyword($enable = true)
+    {
+        $this->addWhereKeyword = $enable;
+    }
 }