Code Duplication    Length = 27-27 lines in 4 locations

src/Drivers/PDO/PDODriver.php 1 location

@@ 158-184 (lines=27) @@
155
	 *
156
	 * @return array|string array or string. escaped. obviously.
157
	 */
158
	public function escape($data, $specialchars = false){
159
160
		if(is_array($data)){
161
162
			foreach($data as $key => $value){
163
				$data[$key] = $this->escape($value, $specialchars);
164
			}
165
166
		}
167
		else if(is_object($data)){
168
169
			foreach($data as $key => $value){
170
				$data->{$key} = $this->escape($value, $specialchars);
171
			}
172
173
		}
174
		else{
175
176
			if($specialchars){
177
				$data = htmlspecialchars($data, ENT_HTML5, 'UTF-8', false);
178
			}
179
180
			$data = $this->db->quote($data);
181
		}
182
183
		return $data;
184
	}
185
186
	/**
187
	 * @param \PDOStatement $stmt

src/Drivers/PostgreSQL/PostgreSQLDriver.php 1 location

@@ 105-131 (lines=27) @@
102
	 *
103
	 * @return array|string array or string. escaped. obviously.
104
	 */
105
	public function escape($data, $specialchars = false){
106
107
		if(is_array($data)){
108
109
			foreach($data as $key => $value){
110
				$data[$key] = $this->escape($value, $specialchars);
111
			}
112
113
		}
114
		else if(is_object($data)){
115
116
			foreach($data as $key => $value){
117
				$data->{$key} = $this->escape($value, $specialchars);
118
			}
119
120
		}
121
		else{
122
123
			if($specialchars){
124
				$data = htmlspecialchars($data, ENT_HTML5, 'UTF-8', false);
125
			}
126
127
			$data = pg_escape_string($this->db, $data);
128
		}
129
130
		return $data;
131
	}
132
133
	/**
134
	 * Basic SQL query for non prepared statements

src/Drivers/SQLite/SQLite3Driver.php 1 location

@@ 96-122 (lines=27) @@
93
	 *
94
	 * @return array|string array or string. escaped. obviously.
95
	 */
96
	public function escape($data, $specialchars = false){
97
98
		if(is_array($data)){
99
100
			foreach($data as $key => $value){
101
				$data[$key] = $this->escape($value, $specialchars);
102
			}
103
104
		}
105
		else if(is_object($data)){
106
107
			foreach($data as $key => $value){
108
				$data->{$key} = $this->escape($value, $specialchars);
109
			}
110
111
		}
112
		else{
113
114
			if($specialchars){
115
				$data = htmlspecialchars($data, ENT_HTML5, 'UTF-8', false);
116
			}
117
118
			$data = SQLite3::escapeString($data);
119
		}
120
121
		return $data;
122
	}
123
124
	/**
125
	 * Basic SQL query for non prepared statements

src/Drivers/MySQLi/MySQLiDriver.php 1 location

@@ 124-150 (lines=27) @@
121
	 *
122
	 * @return array|string array or string. escaped. obviously.
123
	 */
124
	public function escape($data, $specialchars = false){
125
126
		if(is_array($data)){
127
128
			foreach($data as $key => $value){
129
				$data[$key] = $this->escape($value, $specialchars);
130
			}
131
132
		}
133
		else if(is_object($data)){
134
135
			foreach($data as $key => $value){
136
				$data->{$key} = $this->escape($value, $specialchars);
137
			}
138
139
		}
140
		else{
141
142
			if($specialchars){
143
				$data = htmlspecialchars($data, ENT_HTML5, 'UTF-8', false);
144
			}
145
146
			$data = $this->db->real_escape_string($data);
147
		}
148
149
		return $data;
150
	}
151
152
	/**
153
	 * Basic SQL query for non prepared statements