Passed
Branch master (73cfe8)
by Ondřej
06:41
created
src/Ivory/Type/CompositeType.php 2 patches
Indentation   +214 added lines, -214 removed lines patch added patch discarded remove patch
@@ -20,223 +20,223 @@
 block discarded – undo
20 20
  */
21 21
 abstract class CompositeType implements INamedType, ITotallyOrderedType
22 22
 {
23
-	/** @var IType[] ordered map: attribute name => attribute type */
24
-	private $attributes = [];
25
-	/** @var int[] map: attribute name => position of the attribute within the composite type */
26
-	private $attNameMap = [];
27
-
28
-
29
-	public function __construct()
30
-	{
31
-	}
32
-
33
-	/**
34
-	 * Defines a new attribute of this composite type.
35
-	 *
36
-	 * @param string $attName
37
-	 * @param IType $attType
38
-	 */
39
-	public function addAttribute($attName, IType $attType)
40
-	{
41
-		if ((string)$attName == '') {
42
-			$typeName = "{$this->getSchemaName()}.{$this->getName()}";
43
-			$msg = "No attribute name given when adding attribute to composite type $typeName";
44
-			throw new \InvalidArgumentException($msg);
45
-		}
46
-		if (isset($this->attributes[$attName])) {
47
-			$typeName = "{$this->getSchemaName()}.{$this->getName()}";
48
-			throw new \RuntimeException("Attribute '$attName' already defined on composite type $typeName");
49
-		}
50
-		$this->attributes[$attName] = $attType;
51
-		$this->attNameMap[$attName] = count($this->attNameMap);
52
-	}
53
-
54
-	/**
55
-	 * @return IType[] ordered map: attribute name => attribute type
56
-	 */
57
-	public function getAttributes()
58
-	{
59
-		return $this->attributes;
60
-	}
61
-
62
-	/**
63
-	 * @param string $attName name of an attribute, previously defined by {@link addAttribute()}
64
-	 * @return int|null zero-based position of the given attribute, or <tt>null</tt> if no such attribute is defined
65
-	 */
66
-	public function getAttPos($attName)
67
-	{
68
-		return (isset($this->attNameMap[$attName]) ? $this->attNameMap[$attName] : null);
69
-	}
70
-
71
-	public function parseValue($str)
72
-	{
73
-		if ($str === null) {
74
-			return null;
75
-		}
76
-		if ($str == '()' && !$this->attributes) {
77
-			return Composite::fromList($this, []);
78
-		}
79
-
80
-		$strLen = strlen($str);
81
-		if ($str[0] != '(' || $str[$strLen - 1] != ')') {
82
-			throw new \InvalidArgumentException('Invalid value for a composite type - not enclosed in parentheses');
83
-		}
84
-		$strOffset = 1;
85
-
86
-		$attRegex = '~
23
+    /** @var IType[] ordered map: attribute name => attribute type */
24
+    private $attributes = [];
25
+    /** @var int[] map: attribute name => position of the attribute within the composite type */
26
+    private $attNameMap = [];
27
+
28
+
29
+    public function __construct()
30
+    {
31
+    }
32
+
33
+    /**
34
+     * Defines a new attribute of this composite type.
35
+     *
36
+     * @param string $attName
37
+     * @param IType $attType
38
+     */
39
+    public function addAttribute($attName, IType $attType)
40
+    {
41
+        if ((string)$attName == '') {
42
+            $typeName = "{$this->getSchemaName()}.{$this->getName()}";
43
+            $msg = "No attribute name given when adding attribute to composite type $typeName";
44
+            throw new \InvalidArgumentException($msg);
45
+        }
46
+        if (isset($this->attributes[$attName])) {
47
+            $typeName = "{$this->getSchemaName()}.{$this->getName()}";
48
+            throw new \RuntimeException("Attribute '$attName' already defined on composite type $typeName");
49
+        }
50
+        $this->attributes[$attName] = $attType;
51
+        $this->attNameMap[$attName] = count($this->attNameMap);
52
+    }
53
+
54
+    /**
55
+     * @return IType[] ordered map: attribute name => attribute type
56
+     */
57
+    public function getAttributes()
58
+    {
59
+        return $this->attributes;
60
+    }
61
+
62
+    /**
63
+     * @param string $attName name of an attribute, previously defined by {@link addAttribute()}
64
+     * @return int|null zero-based position of the given attribute, or <tt>null</tt> if no such attribute is defined
65
+     */
66
+    public function getAttPos($attName)
67
+    {
68
+        return (isset($this->attNameMap[$attName]) ? $this->attNameMap[$attName] : null);
69
+    }
70
+
71
+    public function parseValue($str)
72
+    {
73
+        if ($str === null) {
74
+            return null;
75
+        }
76
+        if ($str == '()' && !$this->attributes) {
77
+            return Composite::fromList($this, []);
78
+        }
79
+
80
+        $strLen = strlen($str);
81
+        if ($str[0] != '(' || $str[$strLen - 1] != ')') {
82
+            throw new \InvalidArgumentException('Invalid value for a composite type - not enclosed in parentheses');
83
+        }
84
+        $strOffset = 1;
85
+
86
+        $attRegex = '~
87 87
 		              "(?:[^"\\\\]|""|\\\\.)*"      # either a double-quoted string (backslashes used for escaping, or
88 88
 		                                            # double quotes doubled for a single double-quote character),
89 89
                       |                             # or an unquoted string of characters which do not confuse the
90 90
                       (?:[^"()\\\\,]|\\\\.)+        # parser or are backslash-escaped
91 91
 		             ~x';
92
-		preg_match_all($attRegex, $str, $matches, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE, $strOffset);
93
-		$atts = [];
94
-		foreach ($matches[0] as list($att, $attOffset)) {
95
-			for (; $strOffset < $attOffset; $strOffset++) {
96
-				if ($str[$strOffset] == ',') {
97
-					$atts[] = null;
98
-				}
99
-				else {
100
-					$msg = "Invalid value for a composite type - expecting ',' instead of '{$str[$strOffset]}' at offset $strOffset";
101
-					throw new \InvalidArgumentException($msg);
102
-				}
103
-			}
104
-			$cont = ($att[0] == '"' ? substr($att, 1, -1) : $att);
105
-			$atts[] = preg_replace(['~\\\\(.)~', '~""~'], ['$1', '"'], $cont);
106
-			$strOffset += strlen($att);
107
-			if (!($str[$strOffset] == ',' || ($str[$strOffset] == ')' && $strOffset == $strLen - 1))) {
108
-				$msg = "Invalid value for a composite type - expecting ',' instead of '{$str[$strOffset]}' at offset $strOffset";
109
-				throw new \InvalidArgumentException($msg);
110
-			}
111
-			$strOffset++;
112
-		}
113
-		for (; $strOffset < $strLen; $strOffset++) {
114
-			if ($str[$strOffset] == ',' || ($str[$strOffset] == ')' && $strOffset == $strLen - 1)) {
115
-				$atts[] = null;
116
-			}
117
-			else {
118
-				$msg = "Invalid value for a composite type - expecting ',' instead of '{$str[$strOffset]}' at offset $strOffset";
119
-				throw new \InvalidArgumentException($msg);
120
-			}
121
-		}
122
-
123
-		/** @var IType[] $types */
124
-		$types = array_values($this->attributes);
125
-		if ($types) {
126
-			if (count($atts) != count($types)) {
127
-				throw new \InvalidArgumentException(sprintf(
128
-					'Invalid number of composite value attributes - expecting %d, parsed %d',
129
-					count($types), count($atts)
130
-				));
131
-			}
132
-			else {
133
-				$values = [];
134
-				foreach ($atts as $i => $v) {
135
-					$values[] = $types[$i]->parseValue($v);
136
-				}
137
-			}
138
-		}
139
-		else {
140
-			$values = $atts;
141
-		}
142
-
143
-		return Composite::fromList($this, $values);
144
-	}
145
-
146
-	public function serializeValue($val)
147
-	{
148
-		if ($val === null) {
149
-			return 'NULL';
150
-		}
151
-		elseif ($val instanceof Composite) {
152
-			/** @var IType[] $types */
153
-			$types = array_values($val->getType()->getAttributes());
154
-			if ($types) {
155
-				$itemList = $val->toList();
156
-				if (count($itemList) != count($types)) {
157
-					throw new \InvalidArgumentException(sprintf(
158
-						'Invalid number of composite value attributes - expecting %d, given %d',
159
-						count($types), count($itemList)
160
-					));
161
-				}
162
-				$items = [];
163
-				foreach ($itemList as $i => $v) {
164
-					$items[] = $types[$i]->serializeValue($v);
165
-				}
166
-				return self::serializeItems($items);
167
-			}
168
-			else {
169
-				$values = $val->toList();
170
-			}
171
-		}
172
-		elseif (is_array($val)) {
173
-			$values = $val;
174
-		}
175
-		else {
176
-			$message = "Value '$val' is not valid for type {$this->getSchemaName()}.{$this->getName()}";
177
-			throw new \InvalidArgumentException($message);
178
-		}
179
-
180
-		$items = [];
181
-		foreach ($values as $v) {
182
-			$items[] = ($v === null ? 'NULL' : "'" . strtr((string)$v, ["'" => "''"]) . "'");
183
-		}
184
-		return self::serializeItems($items);
185
-	}
186
-
187
-	private static function serializeItems($items)
188
-	{
189
-		$res = '(' . implode(',', $items) . ')';
190
-		if (count($items) < 2) {
191
-			$res = 'ROW' . $res;
192
-		}
193
-		return $res;
194
-	}
195
-
196
-	public function compareValues($a, $b)
197
-	{
198
-		if ($a === null || $b === null) {
199
-			return null;
200
-		}
201
-
202
-		if (!$a instanceof Composite) {
203
-			throw new IncomparableException('$a is not a ' . Composite::class);
204
-		}
205
-		if (!$b instanceof Composite) {
206
-			throw new IncomparableException('$b is not a ' . Composite::class);
207
-		}
208
-		if ($a->getType() !== $b->getType()) {
209
-			throw new IncomparableException('Different composite types');
210
-		}
211
-		$t = $a->getType();
212
-		if ($t->attributes) {
213
-			foreach ($t->attributes as $att => $type) {
214
-				if ($type instanceof ITotallyOrderedType) {
215
-					$xComp = $type->compareValues($a[$att], $b[$att]);
216
-					if ($xComp) {
217
-						return $xComp;
218
-					}
219
-				}
220
-				else {
221
-					throw new UnsupportedException("The composite {$this->getSchemaName()}.{$this->getName()} attribute $att type $type is not totally ordered.");
222
-				}
223
-			}
224
-			return 0;
225
-		}
226
-		else {
227
-			$al = $a->toList();
228
-			$bl = $b->toList();
229
-			if (count($al) != count($bl)) {
230
-				throw new IncomparableException('Unequal number of composite components');
231
-			}
232
-			foreach ($al as $i => $av) {
233
-				$bv = $bl[$i];
234
-				$xComp = strcmp((string)$av, (string)$bv);
235
-				if ($xComp) {
236
-					return $xComp;
237
-				}
238
-			}
239
-			return 0;
240
-		}
241
-	}
92
+        preg_match_all($attRegex, $str, $matches, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE, $strOffset);
93
+        $atts = [];
94
+        foreach ($matches[0] as list($att, $attOffset)) {
95
+            for (; $strOffset < $attOffset; $strOffset++) {
96
+                if ($str[$strOffset] == ',') {
97
+                    $atts[] = null;
98
+                }
99
+                else {
100
+                    $msg = "Invalid value for a composite type - expecting ',' instead of '{$str[$strOffset]}' at offset $strOffset";
101
+                    throw new \InvalidArgumentException($msg);
102
+                }
103
+            }
104
+            $cont = ($att[0] == '"' ? substr($att, 1, -1) : $att);
105
+            $atts[] = preg_replace(['~\\\\(.)~', '~""~'], ['$1', '"'], $cont);
106
+            $strOffset += strlen($att);
107
+            if (!($str[$strOffset] == ',' || ($str[$strOffset] == ')' && $strOffset == $strLen - 1))) {
108
+                $msg = "Invalid value for a composite type - expecting ',' instead of '{$str[$strOffset]}' at offset $strOffset";
109
+                throw new \InvalidArgumentException($msg);
110
+            }
111
+            $strOffset++;
112
+        }
113
+        for (; $strOffset < $strLen; $strOffset++) {
114
+            if ($str[$strOffset] == ',' || ($str[$strOffset] == ')' && $strOffset == $strLen - 1)) {
115
+                $atts[] = null;
116
+            }
117
+            else {
118
+                $msg = "Invalid value for a composite type - expecting ',' instead of '{$str[$strOffset]}' at offset $strOffset";
119
+                throw new \InvalidArgumentException($msg);
120
+            }
121
+        }
122
+
123
+        /** @var IType[] $types */
124
+        $types = array_values($this->attributes);
125
+        if ($types) {
126
+            if (count($atts) != count($types)) {
127
+                throw new \InvalidArgumentException(sprintf(
128
+                    'Invalid number of composite value attributes - expecting %d, parsed %d',
129
+                    count($types), count($atts)
130
+                ));
131
+            }
132
+            else {
133
+                $values = [];
134
+                foreach ($atts as $i => $v) {
135
+                    $values[] = $types[$i]->parseValue($v);
136
+                }
137
+            }
138
+        }
139
+        else {
140
+            $values = $atts;
141
+        }
142
+
143
+        return Composite::fromList($this, $values);
144
+    }
145
+
146
+    public function serializeValue($val)
147
+    {
148
+        if ($val === null) {
149
+            return 'NULL';
150
+        }
151
+        elseif ($val instanceof Composite) {
152
+            /** @var IType[] $types */
153
+            $types = array_values($val->getType()->getAttributes());
154
+            if ($types) {
155
+                $itemList = $val->toList();
156
+                if (count($itemList) != count($types)) {
157
+                    throw new \InvalidArgumentException(sprintf(
158
+                        'Invalid number of composite value attributes - expecting %d, given %d',
159
+                        count($types), count($itemList)
160
+                    ));
161
+                }
162
+                $items = [];
163
+                foreach ($itemList as $i => $v) {
164
+                    $items[] = $types[$i]->serializeValue($v);
165
+                }
166
+                return self::serializeItems($items);
167
+            }
168
+            else {
169
+                $values = $val->toList();
170
+            }
171
+        }
172
+        elseif (is_array($val)) {
173
+            $values = $val;
174
+        }
175
+        else {
176
+            $message = "Value '$val' is not valid for type {$this->getSchemaName()}.{$this->getName()}";
177
+            throw new \InvalidArgumentException($message);
178
+        }
179
+
180
+        $items = [];
181
+        foreach ($values as $v) {
182
+            $items[] = ($v === null ? 'NULL' : "'" . strtr((string)$v, ["'" => "''"]) . "'");
183
+        }
184
+        return self::serializeItems($items);
185
+    }
186
+
187
+    private static function serializeItems($items)
188
+    {
189
+        $res = '(' . implode(',', $items) . ')';
190
+        if (count($items) < 2) {
191
+            $res = 'ROW' . $res;
192
+        }
193
+        return $res;
194
+    }
195
+
196
+    public function compareValues($a, $b)
197
+    {
198
+        if ($a === null || $b === null) {
199
+            return null;
200
+        }
201
+
202
+        if (!$a instanceof Composite) {
203
+            throw new IncomparableException('$a is not a ' . Composite::class);
204
+        }
205
+        if (!$b instanceof Composite) {
206
+            throw new IncomparableException('$b is not a ' . Composite::class);
207
+        }
208
+        if ($a->getType() !== $b->getType()) {
209
+            throw new IncomparableException('Different composite types');
210
+        }
211
+        $t = $a->getType();
212
+        if ($t->attributes) {
213
+            foreach ($t->attributes as $att => $type) {
214
+                if ($type instanceof ITotallyOrderedType) {
215
+                    $xComp = $type->compareValues($a[$att], $b[$att]);
216
+                    if ($xComp) {
217
+                        return $xComp;
218
+                    }
219
+                }
220
+                else {
221
+                    throw new UnsupportedException("The composite {$this->getSchemaName()}.{$this->getName()} attribute $att type $type is not totally ordered.");
222
+                }
223
+            }
224
+            return 0;
225
+        }
226
+        else {
227
+            $al = $a->toList();
228
+            $bl = $b->toList();
229
+            if (count($al) != count($bl)) {
230
+                throw new IncomparableException('Unequal number of composite components');
231
+            }
232
+            foreach ($al as $i => $av) {
233
+                $bv = $bl[$i];
234
+                $xComp = strcmp((string)$av, (string)$bv);
235
+                if ($xComp) {
236
+                    return $xComp;
237
+                }
238
+            }
239
+            return 0;
240
+        }
241
+    }
242 242
 }
Please login to merge, or discard this patch.
Braces   +10 added lines, -20 removed lines patch added patch discarded remove patch
@@ -95,8 +95,7 @@  discard block
 block discarded – undo
95 95
 			for (; $strOffset < $attOffset; $strOffset++) {
96 96
 				if ($str[$strOffset] == ',') {
97 97
 					$atts[] = null;
98
-				}
99
-				else {
98
+				} else {
100 99
 					$msg = "Invalid value for a composite type - expecting ',' instead of '{$str[$strOffset]}' at offset $strOffset";
101 100
 					throw new \InvalidArgumentException($msg);
102 101
 				}
@@ -113,8 +112,7 @@  discard block
 block discarded – undo
113 112
 		for (; $strOffset < $strLen; $strOffset++) {
114 113
 			if ($str[$strOffset] == ',' || ($str[$strOffset] == ')' && $strOffset == $strLen - 1)) {
115 114
 				$atts[] = null;
116
-			}
117
-			else {
115
+			} else {
118 116
 				$msg = "Invalid value for a composite type - expecting ',' instead of '{$str[$strOffset]}' at offset $strOffset";
119 117
 				throw new \InvalidArgumentException($msg);
120 118
 			}
@@ -128,15 +126,13 @@  discard block
 block discarded – undo
128 126
 					'Invalid number of composite value attributes - expecting %d, parsed %d',
129 127
 					count($types), count($atts)
130 128
 				));
131
-			}
132
-			else {
129
+			} else {
133 130
 				$values = [];
134 131
 				foreach ($atts as $i => $v) {
135 132
 					$values[] = $types[$i]->parseValue($v);
136 133
 				}
137 134
 			}
138
-		}
139
-		else {
135
+		} else {
140 136
 			$values = $atts;
141 137
 		}
142 138
 
@@ -147,8 +143,7 @@  discard block
 block discarded – undo
147 143
 	{
148 144
 		if ($val === null) {
149 145
 			return 'NULL';
150
-		}
151
-		elseif ($val instanceof Composite) {
146
+		} elseif ($val instanceof Composite) {
152 147
 			/** @var IType[] $types */
153 148
 			$types = array_values($val->getType()->getAttributes());
154 149
 			if ($types) {
@@ -164,15 +159,12 @@  discard block
 block discarded – undo
164 159
 					$items[] = $types[$i]->serializeValue($v);
165 160
 				}
166 161
 				return self::serializeItems($items);
167
-			}
168
-			else {
162
+			} else {
169 163
 				$values = $val->toList();
170 164
 			}
171
-		}
172
-		elseif (is_array($val)) {
165
+		} elseif (is_array($val)) {
173 166
 			$values = $val;
174
-		}
175
-		else {
167
+		} else {
176 168
 			$message = "Value '$val' is not valid for type {$this->getSchemaName()}.{$this->getName()}";
177 169
 			throw new \InvalidArgumentException($message);
178 170
 		}
@@ -216,14 +208,12 @@  discard block
 block discarded – undo
216 208
 					if ($xComp) {
217 209
 						return $xComp;
218 210
 					}
219
-				}
220
-				else {
211
+				} else {
221 212
 					throw new UnsupportedException("The composite {$this->getSchemaName()}.{$this->getName()} attribute $att type $type is not totally ordered.");
222 213
 				}
223 214
 			}
224 215
 			return 0;
225
-		}
226
-		else {
216
+		} else {
227 217
 			$al = $a->toList();
228 218
 			$bl = $b->toList();
229 219
 			if (count($al) != count($bl)) {
Please login to merge, or discard this patch.
src/Ivory/Type/EnumType.php 1 patch
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -20,8 +20,7 @@  discard block
 block discarded – undo
20 20
     {
21 21
         if ($str === null) {
22 22
             return null;
23
-        }
24
-        else {
23
+        } else {
25 24
             return $str;
26 25
         }
27 26
     }
@@ -30,8 +29,7 @@  discard block
 block discarded – undo
30 29
     {
31 30
         if ($val === null) {
32 31
             return 'NULL';
33
-        }
34
-        else {
32
+        } else {
35 33
             if (!isset($this->labelSet[$val])) {
36 34
                 $msg = "Value '$val' is not among defined labels of enumeration type {$this->schemaName}.{$this->name}";
37 35
                 trigger_error($msg, E_USER_WARNING);
Please login to merge, or discard this patch.
src/Ivory/Type/NamedCompositeType.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -10,11 +10,11 @@
 block discarded – undo
10 10
  */
11 11
 class NamedCompositeType extends CompositeType
12 12
 {
13
-	use NamedDbObject;
13
+    use NamedDbObject;
14 14
 
15
-	public function __construct($schemaName, $name)
16
-	{
17
-		parent::__construct();
18
-		$this->setName($schemaName, $name);
19
-	}
15
+    public function __construct($schemaName, $name)
16
+    {
17
+        parent::__construct();
18
+        $this->setName($schemaName, $name);
19
+    }
20 20
 }
Please login to merge, or discard this patch.
src/Ivory/Type/TotallyOrderedByPhpOperators.php 1 patch
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -12,11 +12,9 @@
 block discarded – undo
12 12
         // PHP 7: use the <=> operator as a shorthand
13 13
         if ($a < $b) {
14 14
             return -1;
15
-        }
16
-        elseif ($a == $b) {
15
+        } elseif ($a == $b) {
17 16
             return 0;
18
-        }
19
-        else {
17
+        } else {
20 18
             return 1;
21 19
         }
22 20
     }
Please login to merge, or discard this patch.
src/Ivory/Type/BaseType.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -6,24 +6,24 @@
 block discarded – undo
6 6
 
7 7
 abstract class BaseType implements INamedType
8 8
 {
9
-	use NamedDbObject;
9
+    use NamedDbObject;
10 10
 
11
-	private $connection;
11
+    private $connection;
12 12
 
13
-	public function __construct($schemaName, $name, IConnection $connection)
14
-	{
15
-		$this->setName($schemaName, $name);
16
-		$this->connection = $connection;
17
-	}
13
+    public function __construct($schemaName, $name, IConnection $connection)
14
+    {
15
+        $this->setName($schemaName, $name);
16
+        $this->connection = $connection;
17
+    }
18 18
 
19
-	final protected function getConnection()
20
-	{
21
-		return $this->connection;
22
-	}
19
+    final protected function getConnection()
20
+    {
21
+        return $this->connection;
22
+    }
23 23
 
24
-	protected function throwInvalidValue($str, \Exception $cause = null)
25
-	{
26
-		$message = "Value '$str' is not valid for type {$this->schemaName}.{$this->name}";
27
-		throw new \InvalidArgumentException($message, 0, $cause);
28
-	}
24
+    protected function throwInvalidValue($str, \Exception $cause = null)
25
+    {
26
+        $message = "Value '$str' is not valid for type {$this->schemaName}.{$this->name}";
27
+        throw new \InvalidArgumentException($message, 0, $cause);
28
+    }
29 29
 }
Please login to merge, or discard this patch.
src/Ivory/Type/Ivory/IdentifierType.php 2 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -48,13 +48,13 @@
 block discarded – undo
48 48
     }
49 49
 
50 50
     public function compareValues($a, $b)
51
-   	{
52
-   		if ($a === null || $b === null) {
53
-   			return null;
54
-   		}
51
+        {
52
+            if ($a === null || $b === null) {
53
+                return null;
54
+            }
55 55
 
56
-   		return strcmp((string)$a, (string)$b); // FIXME: use the same comparison as StringType
57
-   	}
56
+            return strcmp((string)$a, (string)$b); // FIXME: use the same comparison as StringType
57
+        }
58 58
 
59 59
     private function needsQuotes($val) : bool
60 60
     {
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -27,8 +27,7 @@  discard block
 block discarded – undo
27 27
     {
28 28
         if ($str === null) {
29 29
             return null;
30
-        }
31
-        else {
30
+        } else {
32 31
             return $str;
33 32
         }
34 33
     }
@@ -41,8 +40,7 @@  discard block
 block discarded – undo
41 40
 
42 41
         if ($this->needsQuotes($val)) {
43 42
             return '"' . str_replace('"', '""', $val) . '"';
44
-        }
45
-        else {
43
+        } else {
46 44
             return $val;
47 45
         }
48 46
     }
Please login to merge, or discard this patch.
src/Ivory/Type/Ivory/QuotedIdentifierType.php 2 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -38,10 +38,10 @@
 block discarded – undo
38 38
     }
39 39
 
40 40
     public function compareValues($a, $b)
41
-   	{
42
-   		if ($a === null || $b === null) {
43
-   			return null;
44
-   		}
45
-   		return strcmp((string)$a, (string)$b); // FIXME: use the same comparison as StringType
46
-   	}
41
+        {
42
+            if ($a === null || $b === null) {
43
+                return null;
44
+            }
45
+            return strcmp((string)$a, (string)$b); // FIXME: use the same comparison as StringType
46
+        }
47 47
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,8 +22,7 @@
 block discarded – undo
22 22
     {
23 23
         if ($str === null) {
24 24
             return null;
25
-        }
26
-        else {
25
+        } else {
27 26
             return $str;
28 27
         }
29 28
     }
Please login to merge, or discard this patch.
src/Ivory/Type/IRangeCanonicalFuncProvider.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -6,14 +6,14 @@
 block discarded – undo
6 6
  */
7 7
 interface IRangeCanonicalFuncProvider
8 8
 {
9
-	/**
10
-	 * Provides an implementation of a given canonical function working on a totally ordered type.
11
-	 *
12
-	 * @param string $schemaName name of schema the canonical function is defined in
13
-	 * @param string $funcName name of the canonical function; just the name, without parentheses or arguments
14
-	 * @param ITotallyOrderedType $subtype subtype for the canonical function to work on
15
-	 * @return IRangeCanonicalFunc|null the implementation of the range canonical function, or
16
-	 *                                  <tt>null</tt> if this provider has no matching implementation
17
-	 */
18
-	function provideCanonicalFunc($schemaName, $funcName, ITotallyOrderedType $subtype);
9
+    /**
10
+     * Provides an implementation of a given canonical function working on a totally ordered type.
11
+     *
12
+     * @param string $schemaName name of schema the canonical function is defined in
13
+     * @param string $funcName name of the canonical function; just the name, without parentheses or arguments
14
+     * @param ITotallyOrderedType $subtype subtype for the canonical function to work on
15
+     * @return IRangeCanonicalFunc|null the implementation of the range canonical function, or
16
+     *                                  <tt>null</tt> if this provider has no matching implementation
17
+     */
18
+    function provideCanonicalFunc($schemaName, $funcName, ITotallyOrderedType $subtype);
19 19
 }
Please login to merge, or discard this patch.
src/Ivory/Type/IType.php 1 patch
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -8,26 +8,26 @@
 block discarded – undo
8 8
  */
9 9
 interface IType
10 10
 {
11
-	/**
12
-	 * Parses a value of the represented type from its external representation.
13
-	 *
14
-	 * The external representation is given by the output function of the PostgreSQL type this object represents.
15
-	 * In case `null` is given, `null` is returned.
16
-	 *
17
-	 * @todo for performance reasons, extend with optional arguments $offset and $len, limiting the part of the string to consider; trimming could thus be implemented as just shifting these positions
18
-	 * @param string|null $str
19
-	 * @return mixed the value parsed from <tt>$str</tt>, or <tt>null</tt> if <tt>$str</tt> is <tt>null</tt>
20
-	 */
21
-	function parseValue($str);
11
+    /**
12
+     * Parses a value of the represented type from its external representation.
13
+     *
14
+     * The external representation is given by the output function of the PostgreSQL type this object represents.
15
+     * In case `null` is given, `null` is returned.
16
+     *
17
+     * @todo for performance reasons, extend with optional arguments $offset and $len, limiting the part of the string to consider; trimming could thus be implemented as just shifting these positions
18
+     * @param string|null $str
19
+     * @return mixed the value parsed from <tt>$str</tt>, or <tt>null</tt> if <tt>$str</tt> is <tt>null</tt>
20
+     */
21
+    function parseValue($str);
22 22
 
23
-	/**
24
-	 * Serializes a value of the represented type to a string to be pasted in the SQL query.
25
-	 *
26
-	 * In case `null` is given, the `'NULL'` string is returned.
27
-	 *
28
-	 * @todo unify whether the result shall contain the typecast or not; whether it is necessary depends on the context, so the output of this method shall probably contain no typecasts - the caller should include it, if required
29
-	 * @param mixed $val
30
-	 * @return string
31
-	 */
32
-	function serializeValue($val);
23
+    /**
24
+     * Serializes a value of the represented type to a string to be pasted in the SQL query.
25
+     *
26
+     * In case `null` is given, the `'NULL'` string is returned.
27
+     *
28
+     * @todo unify whether the result shall contain the typecast or not; whether it is necessary depends on the context, so the output of this method shall probably contain no typecasts - the caller should include it, if required
29
+     * @param mixed $val
30
+     * @return string
31
+     */
32
+    function serializeValue($val);
33 33
 }
Please login to merge, or discard this patch.