@@ -18,12 +18,12 @@ private function __construct() {
1818
1919 /**
2020 * Encrypt parts of a JSON payload using the given parameters and configuration.
21- * @param $payload A JSON string
22- * @param $config A FieldLevelEncryptionConfig instance
23- * @param $params A FieldLevelEncryptionParams instance
21+ * @param string $payload A JSON string
22+ * @param FieldLevelEncryptionConfig $config A FieldLevelEncryptionConfig instance
23+ * @param FieldLevelEncryptionParams|null $params A FieldLevelEncryptionParams instance
2424 * @see FieldLevelEncryptionConfig
2525 * @see FieldLevelEncryptionParams
26- * @return The updated payload
26+ * @return string The updated payload
2727 * @throws EncryptionException
2828 */
2929 public static function encryptPayload ($ payload , $ config , $ params = null ) {
@@ -49,12 +49,12 @@ public static function encryptPayload($payload, $config, $params = null) {
4949
5050 /**
5151 * Decrypt parts of a JSON payload using the given parameters and configuration.
52- * @param $payload A JSON string
53- * @param $config A FieldLevelEncryptionConfig instance
54- * @param $params A FieldLevelEncryptionParams instance
52+ * @param string $payload A JSON string
53+ * @param FieldLevelEncryptionConfig $config A FieldLevelEncryptionConfig instance
54+ * @param FieldLevelEncryptionParams|null $params A FieldLevelEncryptionParams instance
5555 * @see FieldLevelEncryptionConfig
5656 * @see FieldLevelEncryptionParams
57- * @return The updated payload
57+ * @return string The updated payload
5858 * @throws EncryptionException
5959 */
6060 public static function decryptPayload ($ payload , $ config , $ params = null ) {
@@ -79,6 +79,11 @@ public static function decryptPayload($payload, $config, $params = null) {
7979 }
8080
8181 /**
82+ * @param \stdClass $payloadJsonObject
83+ * @param string $jsonPathIn
84+ * @param string $jsonPathOut
85+ * @param FieldLevelEncryptionConfig $config
86+ * @param FieldLevelEncryptionParams|null $params
8287 * @throws EncryptionException
8388 */
8489 private static function encryptPayloadPath ($ payloadJsonObject , $ jsonPathIn , $ jsonPathOut , $ config , $ params ) {
@@ -130,6 +135,11 @@ private static function encryptPayloadPath($payloadJsonObject, $jsonPathIn, $jso
130135 }
131136
132137 /**
138+ * @param \stdClass $payloadJsonObject
139+ * @param string $jsonPathIn
140+ * @param string $jsonPathOut
141+ * @param FieldLevelEncryptionConfig $config
142+ * @param FieldLevelEncryptionParams|null $params
133143 * @throws EncryptionException
134144 */
135145 private static function decryptPayloadPath ($ payloadJsonObject , $ jsonPathIn , $ jsonPathOut , $ config , $ params ) {
@@ -178,6 +188,12 @@ private static function decryptPayloadPath($payloadJsonObject, $jsonPathIn, $jso
178188 }
179189 }
180190
191+ /**
192+ * @param \stdClass $payloadJsonObject
193+ * @param string $jsonPathOut
194+ * @param \stdClass $outJsonObject
195+ * @param mixed $decryptedValue
196+ */
181197 private static function addDecryptedDataToPayload ($ payloadJsonObject , $ jsonPathOut , $ outJsonObject , $ decryptedValue ) {
182198 $ decryptedValueJsonElement = json_decode ($ decryptedValue );
183199 if (is_null ($ decryptedValueJsonElement )) {
@@ -199,10 +215,21 @@ private static function addDecryptedDataToPayload($payloadJsonObject, $jsonPathO
199215 }
200216 }
201217
218+ /**
219+ * @param \stdClass $payloadJsonObject
220+ * @param string $jsonPath
221+ * @return mixed
222+ */
202223 private static function readJsonElement ($ payloadJsonObject , $ jsonPath ) {
203224 return JsonPath::find ($ payloadJsonObject , $ jsonPath );
204225 }
205226
227+ /**
228+ * @param \stdClass $payloadJsonObject
229+ * @param string $jsonPath
230+ * @throws \InvalidArgumentException
231+ * @return mixed
232+ */
206233 private static function readJsonObject ($ payloadJsonObject , $ jsonPath ) {
207234 $ inJsonElement = self ::readJsonElement ($ payloadJsonObject , $ jsonPath );
208235 if (is_null ($ inJsonElement )) {
@@ -214,6 +241,12 @@ private static function readJsonObject($payloadJsonObject, $jsonPath) {
214241 return $ inJsonElement ;
215242 }
216243
244+ /**
245+ * @param \stdClass $payloadJsonObject
246+ * @param string $jsonPathOut
247+ * @throws \InvalidArgumentException
248+ * @return mixed
249+ */
217250 private static function checkOrCreateOutObject ($ payloadJsonObject , $ jsonPathOut ) {
218251 $ outJsonObject = self ::readJsonObject ($ payloadJsonObject , $ jsonPathOut );
219252 if (!is_null ($ outJsonObject )) {
@@ -232,6 +265,11 @@ private static function checkOrCreateOutObject($payloadJsonObject, $jsonPathOut)
232265 return $ parentJsonObject ->$ elementKey ;
233266 }
234267
268+ /**
269+ * @param \stdClass $object
270+ * @param string $key
271+ * @return mixed
272+ */
235273 private static function readAndDeleteJsonKey ($ object , $ key ) {
236274 if (empty ($ key ) || false === property_exists ($ object , $ key )) {
237275 // Do nothing
@@ -242,6 +280,13 @@ private static function readAndDeleteJsonKey($object, $key) {
242280 return $ value ;
243281 }
244282
283+ /**
284+ * @param string $key
285+ * @param string $iv
286+ * @param string $bytes
287+ * @throws EncryptionException
288+ * @return string
289+ */
245290 private static function encryptBytes ($ key , $ iv , $ bytes ) {
246291 $ aes = new AES ();
247292 $ aes ->setKey ($ key );
@@ -253,6 +298,13 @@ private static function encryptBytes($key, $iv, $bytes) {
253298 return $ encryptedBytes ;
254299 }
255300
301+ /**
302+ * @param string $key
303+ * @param string $iv
304+ * @param string $encryptedBytes
305+ * @throws EncryptionException
306+ * @return string
307+ */
256308 private static function decryptBytes ($ key , $ iv , $ encryptedBytes ) {
257309 $ aes = new AES ();
258310 $ aes ->setKey ($ key );
@@ -264,6 +316,10 @@ private static function decryptBytes($key, $iv, $encryptedBytes) {
264316 return $ bytes ;
265317 }
266318
319+ /**
320+ * @param mixed $object
321+ * @return mixed
322+ */
267323 private static function toJsonString ($ object ) {
268324 if (is_null ($ object )) {
269325 throw new \InvalidArgumentException ('Can \'t get a JSON string from a null object! ' );
@@ -274,6 +330,10 @@ private static function toJsonString($object) {
274330 return json_encode ($ object );
275331 }
276332
333+ /**
334+ * @param string $json
335+ * @return string
336+ */
277337 private static function sanitizeJson ($ json ) {
278338 $ json = str_replace ("\n" , '' , $ json );
279339 $ json = str_replace ("\r" , '' , $ json );
0 commit comments