@@ -21,8 +21,7 @@ |
||
21 | 21 | { |
22 | 22 | if ($str === null) { |
23 | 23 | return null; |
24 | - } |
|
25 | - else { |
|
24 | + } else { |
|
26 | 25 | return $str; |
27 | 26 | } |
28 | 27 | } |
@@ -22,8 +22,7 @@ |
||
22 | 22 | |
23 | 23 | try { |
24 | 24 | return NetAddress::fromString($str); |
25 | - } |
|
26 | - catch (\InvalidArgumentException $e) { |
|
25 | + } catch (\InvalidArgumentException $e) { |
|
27 | 26 | $this->throwInvalidValue($str, $e); |
28 | 27 | } |
29 | 28 | } |
@@ -20,8 +20,7 @@ |
||
20 | 20 | if (!$val instanceof Json) { |
21 | 21 | try { |
22 | 22 | $val = Json::fromValue($val); |
23 | - } |
|
24 | - catch (\InvalidArgumentException $e) { |
|
23 | + } catch (\InvalidArgumentException $e) { |
|
25 | 24 | $this->throwInvalidValue($val, $e); |
26 | 25 | } |
27 | 26 | } |
@@ -12,52 +12,52 @@ |
||
12 | 12 | */ |
13 | 13 | class BooleanType extends \Ivory\Type\BaseType implements ITotallyOrderedType |
14 | 14 | { |
15 | - public function parseValue($str) |
|
16 | - { |
|
17 | - if ($str === null) { |
|
18 | - return null; |
|
19 | - } |
|
15 | + public function parseValue($str) |
|
16 | + { |
|
17 | + if ($str === null) { |
|
18 | + return null; |
|
19 | + } |
|
20 | 20 | |
21 | - switch (strtoupper($str)) { |
|
22 | - case 'T': |
|
23 | - case 'TRUE': |
|
24 | - case 'Y': |
|
25 | - case 'YES': |
|
26 | - case 'ON': |
|
27 | - case '1': |
|
28 | - return true; |
|
21 | + switch (strtoupper($str)) { |
|
22 | + case 'T': |
|
23 | + case 'TRUE': |
|
24 | + case 'Y': |
|
25 | + case 'YES': |
|
26 | + case 'ON': |
|
27 | + case '1': |
|
28 | + return true; |
|
29 | 29 | |
30 | - case 'F': |
|
31 | - case 'FALSE': |
|
32 | - case 'N': |
|
33 | - case 'NO': |
|
34 | - case 'OFF': |
|
35 | - case '0': |
|
36 | - return false; |
|
30 | + case 'F': |
|
31 | + case 'FALSE': |
|
32 | + case 'N': |
|
33 | + case 'NO': |
|
34 | + case 'OFF': |
|
35 | + case '0': |
|
36 | + return false; |
|
37 | 37 | |
38 | - default: |
|
39 | - $this->throwInvalidValue($str); |
|
40 | - } |
|
41 | - } |
|
38 | + default: |
|
39 | + $this->throwInvalidValue($str); |
|
40 | + } |
|
41 | + } |
|
42 | 42 | |
43 | - public function serializeValue($val) |
|
44 | - { |
|
45 | - if ($val === null) { |
|
46 | - return 'NULL'; |
|
47 | - } |
|
48 | - elseif ($val) { |
|
49 | - return 'TRUE'; |
|
50 | - } |
|
51 | - else { |
|
52 | - return 'FALSE'; |
|
53 | - } |
|
54 | - } |
|
43 | + public function serializeValue($val) |
|
44 | + { |
|
45 | + if ($val === null) { |
|
46 | + return 'NULL'; |
|
47 | + } |
|
48 | + elseif ($val) { |
|
49 | + return 'TRUE'; |
|
50 | + } |
|
51 | + else { |
|
52 | + return 'FALSE'; |
|
53 | + } |
|
54 | + } |
|
55 | 55 | |
56 | - public function compareValues($a, $b) |
|
57 | - { |
|
58 | - if ($a === null || $b === null) { |
|
59 | - return null; |
|
60 | - } |
|
61 | - return (bool)$a - (bool)$b; |
|
62 | - } |
|
56 | + public function compareValues($a, $b) |
|
57 | + { |
|
58 | + if ($a === null || $b === null) { |
|
59 | + return null; |
|
60 | + } |
|
61 | + return (bool)$a - (bool)$b; |
|
62 | + } |
|
63 | 63 | } |
@@ -44,11 +44,9 @@ |
||
44 | 44 | { |
45 | 45 | if ($val === null) { |
46 | 46 | return 'NULL'; |
47 | - } |
|
48 | - elseif ($val) { |
|
47 | + } elseif ($val) { |
|
49 | 48 | return 'TRUE'; |
50 | - } |
|
51 | - else { |
|
49 | + } else { |
|
52 | 50 | return 'FALSE'; |
53 | 51 | } |
54 | 52 | } |
@@ -12,31 +12,31 @@ |
||
12 | 12 | */ |
13 | 13 | class StringType extends \Ivory\Type\BaseType implements ITotallyOrderedType |
14 | 14 | { |
15 | - public function parseValue($str) |
|
16 | - { |
|
17 | - if ($str === null) { |
|
18 | - return null; |
|
19 | - } |
|
20 | - else { |
|
21 | - return $str; |
|
22 | - } |
|
23 | - } |
|
15 | + public function parseValue($str) |
|
16 | + { |
|
17 | + if ($str === null) { |
|
18 | + return null; |
|
19 | + } |
|
20 | + else { |
|
21 | + return $str; |
|
22 | + } |
|
23 | + } |
|
24 | 24 | |
25 | - public function serializeValue($val) |
|
26 | - { |
|
27 | - if ($val === null) { |
|
28 | - return 'NULL'; |
|
29 | - } |
|
30 | - else { |
|
31 | - return "'" . strtr($val, ["'" => "''"]) . "'"; |
|
32 | - } |
|
33 | - } |
|
25 | + public function serializeValue($val) |
|
26 | + { |
|
27 | + if ($val === null) { |
|
28 | + return 'NULL'; |
|
29 | + } |
|
30 | + else { |
|
31 | + return "'" . strtr($val, ["'" => "''"]) . "'"; |
|
32 | + } |
|
33 | + } |
|
34 | 34 | |
35 | - public function compareValues($a, $b) |
|
36 | - { |
|
37 | - if ($a === null || $b === null) { |
|
38 | - return null; |
|
39 | - } |
|
40 | - return strcmp((string)$a, (string)$b); // FIXME: comparison according to a collation, or at least the client encoding, or at least using UTF-8 |
|
41 | - } |
|
35 | + public function compareValues($a, $b) |
|
36 | + { |
|
37 | + if ($a === null || $b === null) { |
|
38 | + return null; |
|
39 | + } |
|
40 | + return strcmp((string)$a, (string)$b); // FIXME: comparison according to a collation, or at least the client encoding, or at least using UTF-8 |
|
41 | + } |
|
42 | 42 | } |
@@ -16,8 +16,7 @@ discard block |
||
16 | 16 | { |
17 | 17 | if ($str === null) { |
18 | 18 | return null; |
19 | - } |
|
20 | - else { |
|
19 | + } else { |
|
21 | 20 | return $str; |
22 | 21 | } |
23 | 22 | } |
@@ -26,8 +25,7 @@ discard block |
||
26 | 25 | { |
27 | 26 | if ($val === null) { |
28 | 27 | return 'NULL'; |
29 | - } |
|
30 | - else { |
|
28 | + } else { |
|
31 | 29 | return "'" . strtr($val, ["'" => "''"]) . "'"; |
32 | 30 | } |
33 | 31 | } |
@@ -36,22 +36,17 @@ |
||
36 | 36 | if (!$val instanceof TimeTz) { |
37 | 37 | if ($val instanceof \DateTimeInterface) { |
38 | 38 | $val = TimeTz::fromDateTime($val); |
39 | - } |
|
40 | - elseif (is_numeric($val)) { |
|
39 | + } elseif (is_numeric($val)) { |
|
41 | 40 | $val = TimeTz::fromUnixTimestamp($val); |
42 | - } |
|
43 | - elseif (is_string($val)) { |
|
41 | + } elseif (is_string($val)) { |
|
44 | 42 | try { |
45 | 43 | $val = TimeTz::fromString($val); |
46 | - } |
|
47 | - catch (\InvalidArgumentException $e) { |
|
44 | + } catch (\InvalidArgumentException $e) { |
|
48 | 45 | $this->throwInvalidValue($val, $e); |
49 | - } |
|
50 | - catch (\OutOfRangeException $e) { |
|
46 | + } catch (\OutOfRangeException $e) { |
|
51 | 47 | $this->throwInvalidValue($val, $e); |
52 | 48 | } |
53 | - } |
|
54 | - else { |
|
49 | + } else { |
|
55 | 50 | $this->throwInvalidValue($val); |
56 | 51 | } |
57 | 52 | } |
@@ -8,8 +8,8 @@ |
||
8 | 8 | */ |
9 | 9 | class StdTypeLoader implements \Ivory\Type\ITypeLoader |
10 | 10 | { |
11 | - public function loadType($schemaName, $typeName, \Ivory\Connection\IConnection $connection) |
|
12 | - { |
|
11 | + public function loadType($schemaName, $typeName, \Ivory\Connection\IConnection $connection) |
|
12 | + { |
|
13 | 13 | switch ($schemaName) { |
14 | 14 | case 'pg_catalog': |
15 | 15 | switch ($typeName) { |
@@ -12,38 +12,38 @@ |
||
12 | 12 | */ |
13 | 13 | class BinaryType extends \Ivory\Type\BaseType implements ITotallyOrderedType |
14 | 14 | { |
15 | - public function parseValue($str) |
|
16 | - { |
|
17 | - if ($str === null) { |
|
18 | - return null; |
|
19 | - } |
|
15 | + public function parseValue($str) |
|
16 | + { |
|
17 | + if ($str === null) { |
|
18 | + return null; |
|
19 | + } |
|
20 | 20 | |
21 | - /* Depending on the PostgreSQL bytea_output configuration parameter, data may be encoded either in the "hex" or |
|
21 | + /* Depending on the PostgreSQL bytea_output configuration parameter, data may be encoded either in the "hex" or |
|
22 | 22 | * "escape" format, which may be recognized by the '\x' prefix. |
23 | 23 | */ |
24 | - if (substr($str, 0, 2) == '\\x') { |
|
25 | - return hex2bin(substr($str, 2)); |
|
26 | - } |
|
27 | - else { |
|
28 | - return pg_unescape_bytea($str); |
|
29 | - } |
|
30 | - } |
|
24 | + if (substr($str, 0, 2) == '\\x') { |
|
25 | + return hex2bin(substr($str, 2)); |
|
26 | + } |
|
27 | + else { |
|
28 | + return pg_unescape_bytea($str); |
|
29 | + } |
|
30 | + } |
|
31 | 31 | |
32 | - public function serializeValue($val) |
|
33 | - { |
|
34 | - if ($val === null) { |
|
35 | - return 'NULL'; |
|
36 | - } |
|
37 | - else { |
|
38 | - return "E'\\\\x" . bin2hex($val) . "'"; |
|
39 | - } |
|
40 | - } |
|
32 | + public function serializeValue($val) |
|
33 | + { |
|
34 | + if ($val === null) { |
|
35 | + return 'NULL'; |
|
36 | + } |
|
37 | + else { |
|
38 | + return "E'\\\\x" . bin2hex($val) . "'"; |
|
39 | + } |
|
40 | + } |
|
41 | 41 | |
42 | - public function compareValues($a, $b) |
|
43 | - { |
|
44 | - if ($a === null || $b === null) { |
|
45 | - return null; |
|
46 | - } |
|
47 | - return strcmp((string)$a, (string)$b); |
|
48 | - } |
|
42 | + public function compareValues($a, $b) |
|
43 | + { |
|
44 | + if ($a === null || $b === null) { |
|
45 | + return null; |
|
46 | + } |
|
47 | + return strcmp((string)$a, (string)$b); |
|
48 | + } |
|
49 | 49 | } |
@@ -23,8 +23,7 @@ discard block |
||
23 | 23 | */ |
24 | 24 | if (substr($str, 0, 2) == '\\x') { |
25 | 25 | return hex2bin(substr($str, 2)); |
26 | - } |
|
27 | - else { |
|
26 | + } else { |
|
28 | 27 | return pg_unescape_bytea($str); |
29 | 28 | } |
30 | 29 | } |
@@ -33,8 +32,7 @@ discard block |
||
33 | 32 | { |
34 | 33 | if ($val === null) { |
35 | 34 | return 'NULL'; |
36 | - } |
|
37 | - else { |
|
35 | + } else { |
|
38 | 36 | return "E'\\\\x" . bin2hex($val) . "'"; |
39 | 37 | } |
40 | 38 | } |
@@ -10,13 +10,13 @@ |
||
10 | 10 | */ |
11 | 11 | class FixedBitStringType extends BitStringType |
12 | 12 | { |
13 | - public function parseValue($str) |
|
14 | - { |
|
15 | - if ($str === null) { |
|
16 | - return null; |
|
17 | - } |
|
18 | - else { |
|
19 | - return \Ivory\Value\FixedBitString::fromString($str); |
|
20 | - } |
|
21 | - } |
|
13 | + public function parseValue($str) |
|
14 | + { |
|
15 | + if ($str === null) { |
|
16 | + return null; |
|
17 | + } |
|
18 | + else { |
|
19 | + return \Ivory\Value\FixedBitString::fromString($str); |
|
20 | + } |
|
21 | + } |
|
22 | 22 | } |
@@ -14,8 +14,7 @@ |
||
14 | 14 | { |
15 | 15 | if ($str === null) { |
16 | 16 | return null; |
17 | - } |
|
18 | - else { |
|
17 | + } else { |
|
19 | 18 | return \Ivory\Value\FixedBitString::fromString($str); |
20 | 19 | } |
21 | 20 | } |