Passed
Push — master ( b7b77b...565dd3 )
by Glynn
05:12 queued 03:02
created
src/AliasFacade.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@
 block discarded – undo
25 25
      */
26 26
     public static function __callStatic($method, $args)
27 27
     {
28
-        if (!static::$queryBuilderInstance) {
28
+        if ( ! static::$queryBuilderInstance) {
29 29
             static::$queryBuilderInstance = new QueryBuilderHandler();
30 30
         }
31 31
 
Please login to merge, or discard this patch.
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -12,36 +12,36 @@
 block discarded – undo
12 12
  */
13 13
 class AliasFacade
14 14
 {
15
-    /**
16
-     * @var QueryBuilderHandler|null
17
-     */
18
-    protected static $queryBuilderInstance;
15
+	/**
16
+	 * @var QueryBuilderHandler|null
17
+	 */
18
+	protected static $queryBuilderInstance;
19 19
 
20
-    /**
21
-     * @param string $method
22
-     * @param mixed[] $args
23
-     *
24
-     * @return mixed
25
-     */
26
-    public static function __callStatic($method, $args)
27
-    {
28
-        if (!static::$queryBuilderInstance) {
29
-            static::$queryBuilderInstance = new QueryBuilderHandler();
30
-        }
20
+	/**
21
+	 * @param string $method
22
+	 * @param mixed[] $args
23
+	 *
24
+	 * @return mixed
25
+	 */
26
+	public static function __callStatic($method, $args)
27
+	{
28
+		if (!static::$queryBuilderInstance) {
29
+			static::$queryBuilderInstance = new QueryBuilderHandler();
30
+		}
31 31
 
32
-        // Call the non-static method from the class instance
33
-        $callable = [static::$queryBuilderInstance, $method];
32
+		// Call the non-static method from the class instance
33
+		$callable = [static::$queryBuilderInstance, $method];
34 34
 
35
-        return is_callable($callable)
36
-            ? call_user_func_array($callable, $args)
37
-            : null;
38
-    }
35
+		return is_callable($callable)
36
+			? call_user_func_array($callable, $args)
37
+			: null;
38
+	}
39 39
 
40
-    /**
41
-     * @param QueryBuilderHandler $queryBuilderInstance
42
-     */
43
-    public static function setQueryBuilderInstance($queryBuilderInstance): void
44
-    {
45
-        static::$queryBuilderInstance = $queryBuilderInstance;
46
-    }
40
+	/**
41
+	 * @param QueryBuilderHandler $queryBuilderInstance
42
+	 */
43
+	public static function setQueryBuilderInstance($queryBuilderInstance): void
44
+	{
45
+		static::$queryBuilderInstance = $queryBuilderInstance;
46
+	}
47 47
 }
Please login to merge, or discard this patch.
src/Binding.php 2 patches
Indentation   +164 added lines, -164 removed lines patch added patch discarded remove patch
@@ -7,168 +7,168 @@
 block discarded – undo
7 7
 
8 8
 class Binding
9 9
 {
10
-    public const STRING = '%s';
11
-    public const BOOL = '%d';
12
-    public const INT = '%d';
13
-    public const FLOAT = '%f';
14
-    public const JSON = '%s';
15
-    public const RAW = ':RAW';
16
-
17
-    /**
18
-     * Holds the value to bind with
19
-     *
20
-     * @var mixed
21
-     */
22
-    protected $value;
23
-
24
-    /**
25
-     * Denotes the type
26
-     *
27
-     * @var string|null
28
-     */
29
-    protected $type;
30
-
31
-    /**
32
-     * Denotes if the field is a RAW value
33
-     *
34
-     * @var bool
35
-     */
36
-    protected $isRaw = false;
37
-
38
-    /**
39
-     * @param mixed $value
40
-     * @param string|null $type
41
-     */
42
-    public function __construct($value, ?string $type = null)
43
-    {
44
-        $this->verifyType($type);
45
-        $this->value = $value;
46
-        $this->type = $type;
47
-        if (self::RAW === $type) {
48
-            $this->isRaw = true;
49
-        }
50
-    }
51
-
52
-    /**
53
-     * Creates a binding for a String
54
-     *
55
-     * @param mixed $value
56
-     * @return self
57
-     */
58
-    public static function asString($value): self
59
-    {
60
-        return new Binding($value, self::STRING);
61
-    }
62
-
63
-    /**
64
-     * Creates a binding for a Float
65
-     *
66
-     * @param mixed $value
67
-     * @return self
68
-     */
69
-    public static function asFloat($value): self
70
-    {
71
-        return new Binding($value, self::FLOAT);
72
-    }
73
-
74
-    /**
75
-     * Creates a binding for a Int
76
-     *
77
-     * @param mixed $value
78
-     * @return self
79
-     */
80
-    public static function asInt($value): self
81
-    {
82
-        return new Binding($value, self::INT);
83
-    }
84
-
85
-    /**
86
-     * Creates a binding for a Bool
87
-     *
88
-     * @param mixed $value
89
-     * @return self
90
-     */
91
-    public static function asBool($value): self
92
-    {
93
-        return new Binding($value, self::BOOL);
94
-    }
95
-
96
-    /**
97
-     * Creates a binding for a JSON
98
-     *
99
-     * @param mixed $value
100
-     * @return self
101
-     */
102
-    public static function asJSON($value): self
103
-    {
104
-        return new Binding($value, self::JSON);
105
-    }
106
-
107
-    /**
108
-     * Creates a binding for a Raw
109
-     *
110
-     * @param mixed $value
111
-     * @return self
112
-     */
113
-    public static function asRaw($value): self
114
-    {
115
-        return new Binding($value, self::RAW);
116
-    }
117
-
118
-    /**
119
-     * Verifies that the passed type is allowed
120
-     *
121
-     * @param string|null $type
122
-     * @return void
123
-     * @throws Exception if not a valid type.
124
-     */
125
-    protected function verifyType(?string $type): void
126
-    {
127
-        $validTypes = [self::STRING, self::BOOL, self::FLOAT, self::INT, self::JSON, self::RAW];
128
-        if (null !== $type && !in_array($type, $validTypes, true)) {
129
-            throw new Exception("{$type} is not a valid type to use for Bindings.", 1);
130
-        }
131
-    }
132
-
133
-    /**
134
-     * Checks if we have a type that will bind.
135
-     *
136
-     * @return bool
137
-     */
138
-    public function hasTypeDefined(): bool
139
-    {
140
-        return !\in_array($this->type, [null, self::RAW], true);
141
-    }
142
-
143
-    /**
144
-     * Returns the bindings values
145
-     *
146
-     * @return string|int|float|bool|Raw|null
147
-     */
148
-    public function getValue()
149
-    {
150
-        return ! $this->hasTypeDefined()
151
-            ? new Raw($this->value)
152
-            : $this->value;
153
-    }
154
-
155
-    /**
156
-     * Gets the types format Conversion Specifier
157
-     *
158
-     * @return string|null
159
-     */
160
-    public function getType(): ?string
161
-    {
162
-        return $this->type;
163
-    }
164
-
165
-    /**
166
-     * Get denotes if the field is a RAW value
167
-     *
168
-     * @return bool
169
-     */
170
-    public function isRaw(): bool
171
-    {
172
-        return $this->isRaw;
173
-    }
10
+	public const STRING = '%s';
11
+	public const BOOL = '%d';
12
+	public const INT = '%d';
13
+	public const FLOAT = '%f';
14
+	public const JSON = '%s';
15
+	public const RAW = ':RAW';
16
+
17
+	/**
18
+	 * Holds the value to bind with
19
+	 *
20
+	 * @var mixed
21
+	 */
22
+	protected $value;
23
+
24
+	/**
25
+	 * Denotes the type
26
+	 *
27
+	 * @var string|null
28
+	 */
29
+	protected $type;
30
+
31
+	/**
32
+	 * Denotes if the field is a RAW value
33
+	 *
34
+	 * @var bool
35
+	 */
36
+	protected $isRaw = false;
37
+
38
+	/**
39
+	 * @param mixed $value
40
+	 * @param string|null $type
41
+	 */
42
+	public function __construct($value, ?string $type = null)
43
+	{
44
+		$this->verifyType($type);
45
+		$this->value = $value;
46
+		$this->type = $type;
47
+		if (self::RAW === $type) {
48
+			$this->isRaw = true;
49
+		}
50
+	}
51
+
52
+	/**
53
+	 * Creates a binding for a String
54
+	 *
55
+	 * @param mixed $value
56
+	 * @return self
57
+	 */
58
+	public static function asString($value): self
59
+	{
60
+		return new Binding($value, self::STRING);
61
+	}
62
+
63
+	/**
64
+	 * Creates a binding for a Float
65
+	 *
66
+	 * @param mixed $value
67
+	 * @return self
68
+	 */
69
+	public static function asFloat($value): self
70
+	{
71
+		return new Binding($value, self::FLOAT);
72
+	}
73
+
74
+	/**
75
+	 * Creates a binding for a Int
76
+	 *
77
+	 * @param mixed $value
78
+	 * @return self
79
+	 */
80
+	public static function asInt($value): self
81
+	{
82
+		return new Binding($value, self::INT);
83
+	}
84
+
85
+	/**
86
+	 * Creates a binding for a Bool
87
+	 *
88
+	 * @param mixed $value
89
+	 * @return self
90
+	 */
91
+	public static function asBool($value): self
92
+	{
93
+		return new Binding($value, self::BOOL);
94
+	}
95
+
96
+	/**
97
+	 * Creates a binding for a JSON
98
+	 *
99
+	 * @param mixed $value
100
+	 * @return self
101
+	 */
102
+	public static function asJSON($value): self
103
+	{
104
+		return new Binding($value, self::JSON);
105
+	}
106
+
107
+	/**
108
+	 * Creates a binding for a Raw
109
+	 *
110
+	 * @param mixed $value
111
+	 * @return self
112
+	 */
113
+	public static function asRaw($value): self
114
+	{
115
+		return new Binding($value, self::RAW);
116
+	}
117
+
118
+	/**
119
+	 * Verifies that the passed type is allowed
120
+	 *
121
+	 * @param string|null $type
122
+	 * @return void
123
+	 * @throws Exception if not a valid type.
124
+	 */
125
+	protected function verifyType(?string $type): void
126
+	{
127
+		$validTypes = [self::STRING, self::BOOL, self::FLOAT, self::INT, self::JSON, self::RAW];
128
+		if (null !== $type && !in_array($type, $validTypes, true)) {
129
+			throw new Exception("{$type} is not a valid type to use for Bindings.", 1);
130
+		}
131
+	}
132
+
133
+	/**
134
+	 * Checks if we have a type that will bind.
135
+	 *
136
+	 * @return bool
137
+	 */
138
+	public function hasTypeDefined(): bool
139
+	{
140
+		return !\in_array($this->type, [null, self::RAW], true);
141
+	}
142
+
143
+	/**
144
+	 * Returns the bindings values
145
+	 *
146
+	 * @return string|int|float|bool|Raw|null
147
+	 */
148
+	public function getValue()
149
+	{
150
+		return ! $this->hasTypeDefined()
151
+			? new Raw($this->value)
152
+			: $this->value;
153
+	}
154
+
155
+	/**
156
+	 * Gets the types format Conversion Specifier
157
+	 *
158
+	 * @return string|null
159
+	 */
160
+	public function getType(): ?string
161
+	{
162
+		return $this->type;
163
+	}
164
+
165
+	/**
166
+	 * Get denotes if the field is a RAW value
167
+	 *
168
+	 * @return bool
169
+	 */
170
+	public function isRaw(): bool
171
+	{
172
+		return $this->isRaw;
173
+	}
174 174
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
     protected function verifyType(?string $type): void
126 126
     {
127 127
         $validTypes = [self::STRING, self::BOOL, self::FLOAT, self::INT, self::JSON, self::RAW];
128
-        if (null !== $type && !in_array($type, $validTypes, true)) {
128
+        if (null !== $type && ! in_array($type, $validTypes, true)) {
129 129
             throw new Exception("{$type} is not a valid type to use for Bindings.", 1);
130 130
         }
131 131
     }
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
      */
138 138
     public function hasTypeDefined(): bool
139 139
     {
140
-        return !\in_array($this->type, [null, self::RAW], true);
140
+        return ! \in_array($this->type, [null, self::RAW], true);
141 141
     }
142 142
 
143 143
     /**
Please login to merge, or discard this patch.
src/Connection.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@
 block discarded – undo
64 64
         }
65 65
 
66 66
         // Preserve the first database connection with a static property
67
-        if (!static::$storedConnection) {
67
+        if ( ! static::$storedConnection) {
68 68
             static::$storedConnection = $this;
69 69
         }
70 70
     }
Please login to merge, or discard this patch.
Indentation   +194 added lines, -194 removed lines patch added patch discarded remove patch
@@ -11,198 +11,198 @@
 block discarded – undo
11 11
 
12 12
 class Connection
13 13
 {
14
-    /** Config keys */
15
-    public const CLONE_WPDB        = 'clone_wpdb';
16
-    public const PREFIX            = 'prefix';
17
-    public const SHOW_ERRORS       = 'show_errors';
18
-    public const USE_WPDB_PREFIX   = 'use_wpdb_prefix';
19
-
20
-    /**
21
-     * @var Container
22
-     */
23
-    protected $container;
24
-
25
-    /**
26
-     * @var string
27
-     */
28
-    protected $adapter;
29
-
30
-    /**
31
-     * @var array<string, mixed>
32
-     */
33
-    protected $adapterConfig;
34
-
35
-    /**
36
-     * @var wpdb
37
-     */
38
-    protected $dbInstance;
39
-
40
-    /**
41
-     * @var Connection|null
42
-     */
43
-    protected static $storedConnection;
44
-
45
-    /**
46
-     * @var EventHandler
47
-     */
48
-    protected $eventHandler;
49
-
50
-    /**
51
-     * @param wpdb                 $wpdb
52
-     * @param array<string, mixed>  $adapterConfig
53
-     * @param string|null           $alias
54
-     * @param Container|null        $container
55
-     */
56
-    public function __construct(
57
-        wpdb $wpdb,
58
-        array $adapterConfig = [],
59
-        ?string $alias = null,
60
-        ?Container $container = null
61
-    ) {
62
-        $this->setAdapterConfig($adapterConfig);
63
-        $this->dbInstance = $this->configureWpdb($wpdb);
64
-
65
-        $this->container    = $container ?? new Container();
66
-        $this->eventHandler = $this->container->build(EventHandler::class);
67
-
68
-        if ($alias) {
69
-            $this->createAlias($alias);
70
-        }
71
-
72
-        // Preserve the first database connection with a static property
73
-        if (!static::$storedConnection) {
74
-            static::$storedConnection = $this;
75
-        }
76
-    }
77
-
78
-    /**
79
-     * Configures the instance of WPDB based on adaptor config values.
80
-     *
81
-     * @param \wpdb $wpdb
82
-     * @return \wpdb
83
-     */
84
-    protected function configureWpdb(wpdb $wpdb): wpdb
85
-    {
86
-        // Maybe clone instance.
87
-        if (
88
-            array_key_exists(self::CLONE_WPDB, $this->adapterConfig)
89
-            && true === $this->adapterConfig[self::CLONE_WPDB]
90
-        ) {
91
-            $wpdb = clone $wpdb;
92
-        }
93
-
94
-        // Maybe set the prefix to WPDB's.
95
-        if (
96
-            array_key_exists(self::USE_WPDB_PREFIX, $this->adapterConfig)
97
-            && 0 < \mb_strlen($this->adapterConfig[self::USE_WPDB_PREFIX])
98
-        ) {
99
-            $this->adapterConfig[self::PREFIX] = $wpdb->prefix;
100
-        }
101
-
102
-        // Maybe configure errors
103
-        if (array_key_exists(self::SHOW_ERRORS, $this->adapterConfig)) {
104
-            // Based in its value.
105
-            if (true === (bool) $this->adapterConfig[self::SHOW_ERRORS]) {
106
-                $wpdb->show_errors(true);
107
-                $wpdb->suppress_errors(false);
108
-            } else {
109
-                $wpdb->show_errors(false);
110
-                $wpdb->suppress_errors(true);
111
-            }
112
-        }
113
-
114
-        return $wpdb;
115
-    }
116
-
117
-    /**
118
-     * Create an easily accessible query builder alias
119
-     *
120
-     * @param string $alias
121
-     */
122
-    public function createAlias(string $alias): void
123
-    {
124
-        class_alias(AliasFacade::class, $alias);
125
-        $builder = $this->container->build(QueryBuilderHandler::class, [$this]);
126
-        AliasFacade::setQueryBuilderInstance($builder);
127
-    }
128
-
129
-    /**
130
-     * Returns an instance of Query Builder
131
-     */
132
-    public function getQueryBuilder(): QueryBuilderHandler
133
-    {
134
-        return $this->container->build(QueryBuilderHandler::class, [$this]);
135
-    }
136
-
137
-    /**
138
-     * @param wpdb $wpdb
139
-     *
140
-     * @return $this
141
-     */
142
-    public function setDbInstance(wpdb $wpdb)
143
-    {
144
-        $this->dbInstance = $wpdb;
145
-
146
-        return $this;
147
-    }
148
-
149
-    /**
150
-     * @return wpdb
151
-     */
152
-    public function getDbInstance()
153
-    {
154
-        return $this->dbInstance;
155
-    }
156
-
157
-    /**
158
-     * @param array<string, mixed> $adapterConfig
159
-     *
160
-     * @return $this
161
-     */
162
-    public function setAdapterConfig(array $adapterConfig)
163
-    {
164
-        $this->adapterConfig = $adapterConfig;
165
-
166
-        return $this;
167
-    }
168
-
169
-    /**
170
-     * @return array<string, mixed>
171
-     */
172
-    public function getAdapterConfig()
173
-    {
174
-        return $this->adapterConfig;
175
-    }
176
-
177
-    /**
178
-     * @return Container
179
-     */
180
-    public function getContainer()
181
-    {
182
-        return $this->container;
183
-    }
184
-
185
-    /**
186
-     * @return EventHandler
187
-     */
188
-    public function getEventHandler()
189
-    {
190
-        return $this->eventHandler;
191
-    }
192
-
193
-    /**
194
-     * Returns the initial instance created.
195
-     *
196
-     * @return Connection
197
-     *
198
-     * @throws Exception If connection not already established
199
-     */
200
-    public static function getStoredConnection()
201
-    {
202
-        if (null === static::$storedConnection) {
203
-            throw new Exception('No initial instance of Connection created');
204
-        }
205
-
206
-        return static::$storedConnection;
207
-    }
14
+	/** Config keys */
15
+	public const CLONE_WPDB        = 'clone_wpdb';
16
+	public const PREFIX            = 'prefix';
17
+	public const SHOW_ERRORS       = 'show_errors';
18
+	public const USE_WPDB_PREFIX   = 'use_wpdb_prefix';
19
+
20
+	/**
21
+	 * @var Container
22
+	 */
23
+	protected $container;
24
+
25
+	/**
26
+	 * @var string
27
+	 */
28
+	protected $adapter;
29
+
30
+	/**
31
+	 * @var array<string, mixed>
32
+	 */
33
+	protected $adapterConfig;
34
+
35
+	/**
36
+	 * @var wpdb
37
+	 */
38
+	protected $dbInstance;
39
+
40
+	/**
41
+	 * @var Connection|null
42
+	 */
43
+	protected static $storedConnection;
44
+
45
+	/**
46
+	 * @var EventHandler
47
+	 */
48
+	protected $eventHandler;
49
+
50
+	/**
51
+	 * @param wpdb                 $wpdb
52
+	 * @param array<string, mixed>  $adapterConfig
53
+	 * @param string|null           $alias
54
+	 * @param Container|null        $container
55
+	 */
56
+	public function __construct(
57
+		wpdb $wpdb,
58
+		array $adapterConfig = [],
59
+		?string $alias = null,
60
+		?Container $container = null
61
+	) {
62
+		$this->setAdapterConfig($adapterConfig);
63
+		$this->dbInstance = $this->configureWpdb($wpdb);
64
+
65
+		$this->container    = $container ?? new Container();
66
+		$this->eventHandler = $this->container->build(EventHandler::class);
67
+
68
+		if ($alias) {
69
+			$this->createAlias($alias);
70
+		}
71
+
72
+		// Preserve the first database connection with a static property
73
+		if (!static::$storedConnection) {
74
+			static::$storedConnection = $this;
75
+		}
76
+	}
77
+
78
+	/**
79
+	 * Configures the instance of WPDB based on adaptor config values.
80
+	 *
81
+	 * @param \wpdb $wpdb
82
+	 * @return \wpdb
83
+	 */
84
+	protected function configureWpdb(wpdb $wpdb): wpdb
85
+	{
86
+		// Maybe clone instance.
87
+		if (
88
+			array_key_exists(self::CLONE_WPDB, $this->adapterConfig)
89
+			&& true === $this->adapterConfig[self::CLONE_WPDB]
90
+		) {
91
+			$wpdb = clone $wpdb;
92
+		}
93
+
94
+		// Maybe set the prefix to WPDB's.
95
+		if (
96
+			array_key_exists(self::USE_WPDB_PREFIX, $this->adapterConfig)
97
+			&& 0 < \mb_strlen($this->adapterConfig[self::USE_WPDB_PREFIX])
98
+		) {
99
+			$this->adapterConfig[self::PREFIX] = $wpdb->prefix;
100
+		}
101
+
102
+		// Maybe configure errors
103
+		if (array_key_exists(self::SHOW_ERRORS, $this->adapterConfig)) {
104
+			// Based in its value.
105
+			if (true === (bool) $this->adapterConfig[self::SHOW_ERRORS]) {
106
+				$wpdb->show_errors(true);
107
+				$wpdb->suppress_errors(false);
108
+			} else {
109
+				$wpdb->show_errors(false);
110
+				$wpdb->suppress_errors(true);
111
+			}
112
+		}
113
+
114
+		return $wpdb;
115
+	}
116
+
117
+	/**
118
+	 * Create an easily accessible query builder alias
119
+	 *
120
+	 * @param string $alias
121
+	 */
122
+	public function createAlias(string $alias): void
123
+	{
124
+		class_alias(AliasFacade::class, $alias);
125
+		$builder = $this->container->build(QueryBuilderHandler::class, [$this]);
126
+		AliasFacade::setQueryBuilderInstance($builder);
127
+	}
128
+
129
+	/**
130
+	 * Returns an instance of Query Builder
131
+	 */
132
+	public function getQueryBuilder(): QueryBuilderHandler
133
+	{
134
+		return $this->container->build(QueryBuilderHandler::class, [$this]);
135
+	}
136
+
137
+	/**
138
+	 * @param wpdb $wpdb
139
+	 *
140
+	 * @return $this
141
+	 */
142
+	public function setDbInstance(wpdb $wpdb)
143
+	{
144
+		$this->dbInstance = $wpdb;
145
+
146
+		return $this;
147
+	}
148
+
149
+	/**
150
+	 * @return wpdb
151
+	 */
152
+	public function getDbInstance()
153
+	{
154
+		return $this->dbInstance;
155
+	}
156
+
157
+	/**
158
+	 * @param array<string, mixed> $adapterConfig
159
+	 *
160
+	 * @return $this
161
+	 */
162
+	public function setAdapterConfig(array $adapterConfig)
163
+	{
164
+		$this->adapterConfig = $adapterConfig;
165
+
166
+		return $this;
167
+	}
168
+
169
+	/**
170
+	 * @return array<string, mixed>
171
+	 */
172
+	public function getAdapterConfig()
173
+	{
174
+		return $this->adapterConfig;
175
+	}
176
+
177
+	/**
178
+	 * @return Container
179
+	 */
180
+	public function getContainer()
181
+	{
182
+		return $this->container;
183
+	}
184
+
185
+	/**
186
+	 * @return EventHandler
187
+	 */
188
+	public function getEventHandler()
189
+	{
190
+		return $this->eventHandler;
191
+	}
192
+
193
+	/**
194
+	 * Returns the initial instance created.
195
+	 *
196
+	 * @return Connection
197
+	 *
198
+	 * @throws Exception If connection not already established
199
+	 */
200
+	public static function getStoredConnection()
201
+	{
202
+		if (null === static::$storedConnection) {
203
+			throw new Exception('No initial instance of Connection created');
204
+		}
205
+
206
+		return static::$storedConnection;
207
+	}
208 208
 }
Please login to merge, or discard this patch.
src/QueryBuilder/NestedCriteria.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -4,19 +4,19 @@
 block discarded – undo
4 4
 
5 5
 class NestedCriteria extends QueryBuilderHandler
6 6
 {
7
-    /**
8
-     * @param string|Raw $key
9
-     * @param string|mixed|null $operator Can be used as value, if 3rd arg not passed
10
-     * @param mixed|null $value
11
-     * @param string $joiner
12
-     *
13
-     * @return $this
14
-     */
15
-    protected function whereHandler($key, $operator = null, $value = null, $joiner = 'AND')
16
-    {
17
-        $key                            = $this->addTablePrefix($key);
18
-        $this->statements['criteria'][] = compact('key', 'operator', 'value', 'joiner');
7
+	/**
8
+	 * @param string|Raw $key
9
+	 * @param string|mixed|null $operator Can be used as value, if 3rd arg not passed
10
+	 * @param mixed|null $value
11
+	 * @param string $joiner
12
+	 *
13
+	 * @return $this
14
+	 */
15
+	protected function whereHandler($key, $operator = null, $value = null, $joiner = 'AND')
16
+	{
17
+		$key                            = $this->addTablePrefix($key);
18
+		$this->statements['criteria'][] = compact('key', 'operator', 'value', 'joiner');
19 19
 
20
-        return $this;
21
-    }
20
+		return $this;
21
+	}
22 22
 }
Please login to merge, or discard this patch.
src/QueryBuilder/JoinBuilder.php 1 patch
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -4,43 +4,43 @@
 block discarded – undo
4 4
 
5 5
 class JoinBuilder extends QueryBuilderHandler
6 6
 {
7
-    /**
8
-     * @param string|Raw $key
9
-     * @param string|null $operator
10
-     * @param mixed $value
11
-     *
12
-     * @return static
13
-     */
14
-    public function on($key, ?string $operator, $value): self
15
-    {
16
-        return $this->joinHandler($key, $operator, $value, 'AND');
17
-    }
7
+	/**
8
+	 * @param string|Raw $key
9
+	 * @param string|null $operator
10
+	 * @param mixed $value
11
+	 *
12
+	 * @return static
13
+	 */
14
+	public function on($key, ?string $operator, $value): self
15
+	{
16
+		return $this->joinHandler($key, $operator, $value, 'AND');
17
+	}
18 18
 
19
-    /**
20
-     * @param string|Raw $key
21
-     * @param string|null $operator
22
-     * @param mixed $value
23
-     *
24
-     * @return static
25
-     */
26
-    public function orOn($key, ?string $operator, $value): self
27
-    {
28
-        return $this->joinHandler($key, $operator, $value, 'OR');
29
-    }
19
+	/**
20
+	 * @param string|Raw $key
21
+	 * @param string|null $operator
22
+	 * @param mixed $value
23
+	 *
24
+	 * @return static
25
+	 */
26
+	public function orOn($key, ?string $operator, $value): self
27
+	{
28
+		return $this->joinHandler($key, $operator, $value, 'OR');
29
+	}
30 30
 
31
-    /**
32
-     * @param string|Raw $key
33
-     * @param string|null $operator
34
-     * @param mixed $value
35
-     *
36
-     * @return static
37
-     */
38
-    protected function joinHandler($key, ?string $operator = null, $value = null, string $joiner = 'AND'): self
39
-    {
40
-        $key                            = $this->addTablePrefix($key);
41
-        $value                          = $this->addTablePrefix($value);
42
-        $this->statements['criteria'][] = compact('key', 'operator', 'value', 'joiner');
31
+	/**
32
+	 * @param string|Raw $key
33
+	 * @param string|null $operator
34
+	 * @param mixed $value
35
+	 *
36
+	 * @return static
37
+	 */
38
+	protected function joinHandler($key, ?string $operator = null, $value = null, string $joiner = 'AND'): self
39
+	{
40
+		$key                            = $this->addTablePrefix($key);
41
+		$value                          = $this->addTablePrefix($value);
42
+		$this->statements['criteria'][] = compact('key', 'operator', 'value', 'joiner');
43 43
 
44
-        return $this;
45
-    }
44
+		return $this;
45
+	}
46 46
 }
Please login to merge, or discard this patch.
src/QueryBuilder/QueryObject.php 2 patches
Indentation   +60 added lines, -61 removed lines patch added patch discarded remove patch
@@ -6,73 +6,72 @@
 block discarded – undo
6 6
 
7 7
 class QueryObject
8 8
 {
9
-    /**
10
-     * @var string
11
-     */
12
-    protected $sql;
9
+	/**
10
+	 * @var string
11
+	 */
12
+	protected $sql;
13 13
 
14
-    /**
15
-     * @var mixed[]
16
-     */
17
-    protected $bindings = [];
14
+	/**
15
+	 * @var mixed[]
16
+	 */
17
+	protected $bindings = [];
18 18
 
19
-    /**
20
-     * @var wpdb
21
-     */
22
-    protected $dbInstance;
19
+	/**
20
+	 * @var wpdb
21
+	 */
22
+	protected $dbInstance;
23 23
 
24
-    /**
25
-     * @param string $sql
26
-     * @param mixed[] $bindings
27
-     * @param wpdb $dbInstance
28
-     */
29
-    public function __construct(string $sql, array $bindings, wpdb $dbInstance)
30
-    {
31
-        $this->sql        = (string)$sql;
32
-        $this->bindings   = $bindings;
33
-        $this->dbInstance = $dbInstance;
34
-    }
24
+	/**
25
+	 * @param string $sql
26
+	 * @param mixed[] $bindings
27
+	 * @param wpdb $dbInstance
28
+	 */
29
+	public function __construct(string $sql, array $bindings, wpdb $dbInstance)
30
+	{
31
+		$this->sql        = (string)$sql;
32
+		$this->bindings   = $bindings;
33
+		$this->dbInstance = $dbInstance;
34
+	}
35 35
 
36
-    /**
37
-     * @return string
38
-     */
39
-    public function getSql()
40
-    {
41
-        return $this->sql;
42
-    }
36
+	/**
37
+	 * @return string
38
+	 */
39
+	public function getSql()
40
+	{
41
+		return $this->sql;
42
+	}
43 43
 
44
-    /**
45
-     * @return mixed[]
46
-     */
47
-    public function getBindings()
48
-    {
49
-        return $this->bindings;
50
-    }
44
+	/**
45
+	 * @return mixed[]
46
+	 */
47
+	public function getBindings()
48
+	{
49
+		return $this->bindings;
50
+	}
51 51
 
52
-    /**
53
-     * Get the raw/bound sql
54
-     *
55
-     * @return string
56
-     */
57
-    public function getRawSql()
58
-    {
59
-        return $this->interpolateQuery($this->sql, $this->bindings);
60
-    }
52
+	/**
53
+	 * Get the raw/bound sql
54
+	 *
55
+	 * @return string
56
+	 */
57
+	public function getRawSql()
58
+	{
59
+		return $this->interpolateQuery($this->sql, $this->bindings);
60
+	}
61 61
 
62
-    /**
63
-     * Uses WPDB::prepare() to interpolate the query passed.
62
+	/**
63
+	 * Uses WPDB::prepare() to interpolate the query passed.
64
+	 *
65
+	 * @param string $query  The sql query with parameter placeholders
66
+	 * @param mixed[]  $params The array of substitution parameters
67
+	 *
68
+	 * @return string The interpolated query
69
+	 */
70
+	protected function interpolateQuery($query, $params): string
71
+	{
72
+		// Only call this when we have valid params (avoids wpdb::prepare() incorrectly called error)
73
+		$value = empty($params) ? $query : $this->dbInstance->prepare($query, $params);
64 74
 
65
-     *
66
-     * @param string $query  The sql query with parameter placeholders
67
-     * @param mixed[]  $params The array of substitution parameters
68
-     *
69
-     * @return string The interpolated query
70
-     */
71
-    protected function interpolateQuery($query, $params): string
72
-    {
73
-        // Only call this when we have valid params (avoids wpdb::prepare() incorrectly called error)
74
-        $value = empty($params) ? $query : $this->dbInstance->prepare($query, $params);
75
-
76
-        return is_string($value) ? $value : '';
77
-    }
75
+		return is_string($value) ? $value : '';
76
+	}
78 77
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@
 block discarded – undo
28 28
      */
29 29
     public function __construct(string $sql, array $bindings, wpdb $dbInstance)
30 30
     {
31
-        $this->sql        = (string)$sql;
31
+        $this->sql        = (string) $sql;
32 32
         $this->bindings   = $bindings;
33 33
         $this->dbInstance = $dbInstance;
34 34
     }
Please login to merge, or discard this patch.
src/QueryBuilder/Raw.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,8 +20,8 @@  discard block
 block discarded – undo
20 20
      */
21 21
     public function __construct($value, $bindings = [])
22 22
     {
23
-        $this->value    = (string)$value;
24
-        $this->bindings = (array)$bindings;
23
+        $this->value    = (string) $value;
24
+        $this->bindings = (array) $bindings;
25 25
     }
26 26
 
27 27
     /**
@@ -49,6 +49,6 @@  discard block
 block discarded – undo
49 49
      */
50 50
     public function __toString()
51 51
     {
52
-        return (string)$this->value;
52
+        return (string) $this->value;
53 53
     }
54 54
 }
Please login to merge, or discard this patch.
Indentation   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -4,62 +4,62 @@
 block discarded – undo
4 4
 
5 5
 class Raw
6 6
 {
7
-    /**
8
-     * @var string
9
-     */
10
-    protected $value;
7
+	/**
8
+	 * @var string
9
+	 */
10
+	protected $value;
11 11
 
12
-    /**
13
-     * @var mixed[]
14
-     */
15
-    protected $bindings;
12
+	/**
13
+	 * @var mixed[]
14
+	 */
15
+	protected $bindings;
16 16
 
17
-    /**
18
-     * @param string $value
19
-     * @param mixed|mixed[] $bindings
20
-     */
21
-    public function __construct($value, $bindings = [])
22
-    {
23
-        $this->value    = (string)$value;
24
-        $this->bindings = (array)$bindings;
25
-    }
17
+	/**
18
+	 * @param string $value
19
+	 * @param mixed|mixed[] $bindings
20
+	 */
21
+	public function __construct($value, $bindings = [])
22
+	{
23
+		$this->value    = (string)$value;
24
+		$this->bindings = (array)$bindings;
25
+	}
26 26
 
27
-    /**
28
-     * Create a Raw instance with no bindings
29
-     *
30
-     * @param string $value
31
-     * @return self
32
-     */
33
-    public static function val(string $value): self
34
-    {
35
-        return new self($value, []);
36
-    }
27
+	/**
28
+	 * Create a Raw instance with no bindings
29
+	 *
30
+	 * @param string $value
31
+	 * @return self
32
+	 */
33
+	public static function val(string $value): self
34
+	{
35
+		return new self($value, []);
36
+	}
37 37
 
38
-    /**
39
-     * Returns the current bindings
40
-     *
41
-     * @return mixed[]
42
-     */
43
-    public function getBindings(): array
44
-    {
45
-        return $this->bindings;
46
-    }
38
+	/**
39
+	 * Returns the current bindings
40
+	 *
41
+	 * @return mixed[]
42
+	 */
43
+	public function getBindings(): array
44
+	{
45
+		return $this->bindings;
46
+	}
47 47
 
48
-    /**
49
-     * Returns the current value held.
50
-     *
51
-     * @return string
52
-     */
53
-    public function getValue(): string
54
-    {
55
-        return (string) $this->value;
56
-    }
48
+	/**
49
+	 * Returns the current value held.
50
+	 *
51
+	 * @return string
52
+	 */
53
+	public function getValue(): string
54
+	{
55
+		return (string) $this->value;
56
+	}
57 57
 
58
-    /**
59
-     * @return string
60
-     */
61
-    public function __toString()
62
-    {
63
-        return (string)$this->value;
64
-    }
58
+	/**
59
+	 * @return string
60
+	 */
61
+	public function __toString()
62
+	{
63
+		return (string)$this->value;
64
+	}
65 65
 }
Please login to merge, or discard this patch.
src/QueryBuilder/Transaction.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -4,25 +4,25 @@
 block discarded – undo
4 4
 
5 5
 class Transaction extends QueryBuilderHandler
6 6
 {
7
-    /**
8
-     * Commit the database changes
9
-     *
10
-     * @throws TransactionHaltException
11
-     */
12
-    public function commit(): void
13
-    {
14
-        $this->dbInstance->query('COMMIT');
15
-        throw new TransactionHaltException();
16
-    }
7
+	/**
8
+	 * Commit the database changes
9
+	 *
10
+	 * @throws TransactionHaltException
11
+	 */
12
+	public function commit(): void
13
+	{
14
+		$this->dbInstance->query('COMMIT');
15
+		throw new TransactionHaltException();
16
+	}
17 17
 
18
-    /**
19
-     * Rollback the database changes
20
-     *
21
-     * @throws TransactionHaltException
22
-     */
23
-    public function rollback(): void
24
-    {
25
-        $this->dbInstance->query('ROLLBACK');
26
-        throw new TransactionHaltException();
27
-    }
18
+	/**
19
+	 * Rollback the database changes
20
+	 *
21
+	 * @throws TransactionHaltException
22
+	 */
23
+	public function rollback(): void
24
+	{
25
+		$this->dbInstance->query('ROLLBACK');
26
+		throw new TransactionHaltException();
27
+	}
28 28
 }
Please login to merge, or discard this patch.
src/EventHandler.php 2 patches
Indentation   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -8,96 +8,96 @@
 block discarded – undo
8 8
 
9 9
 class EventHandler
10 10
 {
11
-    /**
12
-     * @var array<string, array<string, Closure>>
13
-     */
14
-    protected $events = [];
11
+	/**
12
+	 * @var array<string, array<string, Closure>>
13
+	 */
14
+	protected $events = [];
15 15
 
16
-    /**
17
-     * @var string[]
18
-     */
19
-    protected $firedEvents = [];
16
+	/**
17
+	 * @var string[]
18
+	 */
19
+	protected $firedEvents = [];
20 20
 
21
-    /**
22
-     * @return array<string, array<string, Closure>>
23
-     */
24
-    public function getEvents()
25
-    {
26
-        return $this->events;
27
-    }
21
+	/**
22
+	 * @return array<string, array<string, Closure>>
23
+	 */
24
+	public function getEvents()
25
+	{
26
+		return $this->events;
27
+	}
28 28
 
29
-    /**
30
-     * @param string $event
31
-     * @param string|Raw $table
32
-     *
33
-     * @return Closure|null
34
-     */
35
-    public function getEvent(string $event, $table = ':any'): ?Closure
36
-    {
37
-        if ($table instanceof Raw) {
38
-            return null;
39
-        }
29
+	/**
30
+	 * @param string $event
31
+	 * @param string|Raw $table
32
+	 *
33
+	 * @return Closure|null
34
+	 */
35
+	public function getEvent(string $event, $table = ':any'): ?Closure
36
+	{
37
+		if ($table instanceof Raw) {
38
+			return null;
39
+		}
40 40
 
41
-        return $this->events[$table][$event] ?? null;
42
-    }
41
+		return $this->events[$table][$event] ?? null;
42
+	}
43 43
 
44
-    /**
45
-     * @param string $event
46
-     * @param string|null $table
47
-     * @param Closure $action
48
-     *
49
-     * @return void
50
-     */
51
-    public function registerEvent(string $event, ?string $table, Closure $action)
52
-    {
53
-        $table = $table ?? ':any';
44
+	/**
45
+	 * @param string $event
46
+	 * @param string|null $table
47
+	 * @param Closure $action
48
+	 *
49
+	 * @return void
50
+	 */
51
+	public function registerEvent(string $event, ?string $table, Closure $action)
52
+	{
53
+		$table = $table ?? ':any';
54 54
 
55
-        $this->events[$table][$event] = $action;
56
-    }
55
+		$this->events[$table][$event] = $action;
56
+	}
57 57
 
58
-    /**
59
-     * @param string $event
60
-     * @param string  $table
61
-     *
62
-     * @return void
63
-     */
64
-    public function removeEvent($event, $table = ':any')
65
-    {
66
-        unset($this->events[$table][$event]);
67
-    }
58
+	/**
59
+	 * @param string $event
60
+	 * @param string  $table
61
+	 *
62
+	 * @return void
63
+	 */
64
+	public function removeEvent($event, $table = ':any')
65
+	{
66
+		unset($this->events[$table][$event]);
67
+	}
68 68
 
69
-    /**
70
-     * @param QueryBuilderHandler $queryBuilder
71
-     * @param string $event
72
-     *
73
-     * @return mixed
74
-     */
75
-    public function fireEvents(QueryBuilderHandler $queryBuilder, string $event)
76
-    {
77
-        $statements = $queryBuilder->getStatements();
78
-        $tables     = $statements['tables'] ?? [];
69
+	/**
70
+	 * @param QueryBuilderHandler $queryBuilder
71
+	 * @param string $event
72
+	 *
73
+	 * @return mixed
74
+	 */
75
+	public function fireEvents(QueryBuilderHandler $queryBuilder, string $event)
76
+	{
77
+		$statements = $queryBuilder->getStatements();
78
+		$tables     = $statements['tables'] ?? [];
79 79
 
80
-        // Events added with :any will be fired in case of any table,
81
-        // we are adding :any as a fake table at the beginning.
82
-        array_unshift($tables, ':any');
80
+		// Events added with :any will be fired in case of any table,
81
+		// we are adding :any as a fake table at the beginning.
82
+		array_unshift($tables, ':any');
83 83
 
84
-        // Fire all events
85
-        foreach ($tables as $table) {
86
-            // Fire before events for :any table
87
-            if ($action = $this->getEvent($event, $table)) {
88
-                // Make an event id, with event type and table
89
-                $eventId = $event . $table;
84
+		// Fire all events
85
+		foreach ($tables as $table) {
86
+			// Fire before events for :any table
87
+			if ($action = $this->getEvent($event, $table)) {
88
+				// Make an event id, with event type and table
89
+				$eventId = $event . $table;
90 90
 
91
-                // Fire event
92
-                $handlerParams = func_get_args();
93
-                unset($handlerParams[1]); // we do not need $event
94
-                // Add to fired list
95
-                $this->firedEvents[] = $eventId;
96
-                $result              = call_user_func_array($action, $handlerParams);
97
-                if (!is_null($result)) {
98
-                    return $result;
99
-                }
100
-            }
101
-        }
102
-    }
91
+				// Fire event
92
+				$handlerParams = func_get_args();
93
+				unset($handlerParams[1]); // we do not need $event
94
+				// Add to fired list
95
+				$this->firedEvents[] = $eventId;
96
+				$result              = call_user_func_array($action, $handlerParams);
97
+				if (!is_null($result)) {
98
+					return $result;
99
+				}
100
+			}
101
+		}
102
+	}
103 103
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
             // Fire before events for :any table
87 87
             if ($action = $this->getEvent($event, $table)) {
88 88
                 // Make an event id, with event type and table
89
-                $eventId = $event . $table;
89
+                $eventId = $event.$table;
90 90
 
91 91
                 // Fire event
92 92
                 $handlerParams = func_get_args();
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
                 // Add to fired list
95 95
                 $this->firedEvents[] = $eventId;
96 96
                 $result              = call_user_func_array($action, $handlerParams);
97
-                if (!is_null($result)) {
97
+                if ( ! is_null($result)) {
98 98
                     return $result;
99 99
                 }
100 100
             }
Please login to merge, or discard this patch.