1 | <?php |
||
16 | class EncryptedType extends Type implements OptionalConvertInterface, TypeInterface |
||
17 | { |
||
18 | |||
19 | /** |
||
20 | * Key used for encryption. |
||
21 | * |
||
22 | * @var string|null |
||
23 | */ |
||
24 | protected $key = null; |
||
25 | |||
26 | /** |
||
27 | * Constructor |
||
28 | * |
||
29 | * @param string|null $name The name identifying this type. |
||
30 | */ |
||
31 | 3 | public function __construct($name = null) |
|
36 | |||
37 | /** |
||
38 | * Convert encrypted values to PHP strings or null. |
||
39 | * |
||
40 | * @param mixed $value The value to convert. |
||
41 | * @param \Cake\Database\Driver $driver The driver instance to convert with. |
||
42 | * @return mixed |
||
43 | */ |
||
44 | 3 | public function toPHP($value, Driver $driver) |
|
52 | |||
53 | /** |
||
54 | * Marshalls request data. |
||
55 | * |
||
56 | * @param mixed $value The value to convert. |
||
57 | * @return mixed Converted value. |
||
58 | */ |
||
59 | 3 | public function marshal($value) |
|
71 | |||
72 | /** |
||
73 | * Convert PHP values into the database format. |
||
74 | * |
||
75 | * @param mixed $value The value to convert. |
||
76 | * @param \Cake\Database\Driver $driver The driver instance to convert with. |
||
77 | * @return string |
||
78 | */ |
||
79 | 9 | public function toDatabase($value, Driver $driver) |
|
99 | |||
100 | /** |
||
101 | * Get the correct PDO binding type for string data. |
||
102 | * |
||
103 | * @param mixed $value The value being bound. |
||
104 | * @param \Cake\Database\Driver $driver The driver. |
||
105 | * @return int |
||
106 | */ |
||
107 | 3 | public function toStatement($value, Driver $driver) |
|
115 | |||
116 | /** |
||
117 | * {@inheritDoc} |
||
118 | * |
||
119 | * @return boolean True as database results are returned as encrypted strings. |
||
120 | */ |
||
121 | 3 | public function requiresToPhpCast() |
|
125 | } |
||
126 |