11<?php
2+ declare (strict_types=1 );
3+
24namespace BryanCrowe \EncryptedType \Database \Type ;
35
46use Cake \Core \Configure ;
5- use Cake \Database \Driver ;
6- use Cake \Database \Type ;
7- use Cake \Database \TypeInterface ;
7+ use Cake \Database \DriverInterface ;
8+ use Cake \Database \Type \BaseType ;
89use Cake \Database \Type \OptionalConvertInterface ;
910use Cake \Utility \Security ;
1011use InvalidArgumentException ;
1314/**
1415 * Encrypted BLOB converter. Used to encrypt and decrypt stored data.
1516 */
16- class EncryptedType extends Type implements OptionalConvertInterface, TypeInterface
17+ class EncryptedType extends BaseType implements OptionalConvertInterface
1718{
1819
1920 /**
@@ -38,10 +39,10 @@ public function __construct($name = null)
3839 * Convert encrypted values to PHP strings or null.
3940 *
4041 * @param mixed $value The value to convert.
41- * @param \Cake\Database\Driver $driver The driver instance to convert with.
42- * @return mixed
42+ * @param \Cake\Database\DriverInterface $driver The driver instance to convert with.
43+ * @return string|null
4344 */
44- public function toPHP ($ value , Driver $ driver )
45+ public function toPHP ($ value , DriverInterface $ driver )
4546 {
4647 if ($ value === null ) {
4748 return null ;
@@ -73,10 +74,10 @@ public function marshal($value)
7374 * Convert PHP values into the database format.
7475 *
7576 * @param mixed $value The value to convert.
76- * @param \Cake\Database\Driver $driver The driver instance to convert with.
77- * @return string
77+ * @param \Cake\Database\DriverInterface $driver The driver instance to convert with.
78+ * @return string|null
7879 */
79- public function toDatabase ($ value , Driver $ driver )
80+ public function toDatabase ($ value , DriverInterface $ driver ): ? string
8081 {
8182 if ($ value === null ) {
8283 return null ;
@@ -101,10 +102,10 @@ public function toDatabase($value, Driver $driver)
101102 * Get the correct PDO binding type for string data.
102103 *
103104 * @param mixed $value The value being bound.
104- * @param \Cake\Database\Driver $driver The driver.
105+ * @param \Cake\Database\DriverInterface $driver The driver.
105106 * @return int
106107 */
107- public function toStatement ($ value , Driver $ driver )
108+ public function toStatement ($ value , DriverInterface $ driver )
108109 {
109110 if ($ value === null ) {
110111 return PDO ::PARAM_NULL ;
@@ -118,7 +119,7 @@ public function toStatement($value, Driver $driver)
118119 *
119120 * @return boolean True as database results are returned as encrypted strings.
120121 */
121- public function requiresToPhpCast ()
122+ public function requiresToPhpCast (): bool
122123 {
123124 return true ;
124125 }
0 commit comments