Total Complexity | 8 |
Total Lines | 62 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
17 | class ObjectType extends Type |
||
18 | { |
||
19 | /** |
||
20 | * {@inheritdoc} |
||
21 | */ |
||
22 | 607 | public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform) |
|
23 | { |
||
24 | 607 | return $platform->getBlobTypeDeclarationSQL($fieldDeclaration); |
|
25 | } |
||
26 | |||
27 | /** |
||
28 | * {@inheritdoc} |
||
29 | */ |
||
30 | 81 | public function convertToDatabaseValue($value, AbstractPlatform $platform) |
|
31 | { |
||
32 | 81 | return serialize($value); |
|
33 | } |
||
34 | |||
35 | /** |
||
36 | * {@inheritdoc} |
||
37 | */ |
||
38 | 168 | public function convertToPHPValue($value, AbstractPlatform $platform) |
|
39 | { |
||
40 | 168 | if ($value === null) { |
|
41 | 29 | return null; |
|
42 | } |
||
43 | |||
44 | 139 | $value = is_resource($value) ? stream_get_contents($value) : $value; |
|
45 | |||
46 | set_error_handler(function (int $code, string $message) : void { |
||
47 | 29 | throw ConversionException::conversionFailedUnserialization($this->getName(), $message); |
|
48 | 139 | }); |
|
49 | |||
50 | try { |
||
51 | 139 | return unserialize($value); |
|
52 | } finally { |
||
53 | 139 | restore_error_handler(); |
|
54 | } |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * {@inheritdoc} |
||
59 | */ |
||
60 | 28 | public function getBindingType() : int |
|
61 | { |
||
62 | 28 | return ParameterType::BINARY; |
|
63 | } |
||
64 | |||
65 | /** |
||
66 | * {@inheritdoc} |
||
67 | */ |
||
68 | 984 | public function getName() |
|
71 | } |
||
72 | |||
73 | /** |
||
74 | * {@inheritdoc} |
||
75 | */ |
||
76 | 17768 | public function requiresSQLCommentHint(AbstractPlatform $platform) |
|
79 | } |
||
80 | } |
||
81 |