From 6115778b948e160e4db3584e1dade3fa65c9200f Mon Sep 17 00:00:00 2001 From: neoan Date: Wed, 12 Oct 2022 22:07:37 -0400 Subject: [PATCH] Hashing transformer fix --- src/Model/Interpreter.php | 4 +- src/Model/Transformers/Hash.php | 2 + tests/Mocks/database.db | Bin 32768 -> 32768 bytes tests/clover.xml | 70 ++++++++++++++++---------------- 4 files changed, 41 insertions(+), 35 deletions(-) diff --git a/src/Model/Interpreter.php b/src/Model/Interpreter.php index 10f78da..98bc817 100644 --- a/src/Model/Interpreter.php +++ b/src/Model/Interpreter.php @@ -78,7 +78,9 @@ public function executeAttributes(array $attributes, string $propertyName, Attri foreach ($attributes as $attribute) { if ($attribute['type'] === $type) { $interim = $attribute['instance']($this->currentModel->toArray(), $direction, $propertyName); - $this->currentModel->{$propertyName} = $interim[$propertyName]; + if(isset($interim[$propertyName])){ + $this->currentModel->{$propertyName} = $interim[$propertyName]; + } } } } diff --git a/src/Model/Transformers/Hash.php b/src/Model/Transformers/Hash.php index 7b262d5..ca16b4e 100644 --- a/src/Model/Transformers/Hash.php +++ b/src/Model/Transformers/Hash.php @@ -16,6 +16,8 @@ public function __invoke(array $inputOutput, Direction $direction, string $prope $inputOutput[$property] = $this->fakePassword; } elseif ($direction === Direction::IN && isset($inputOutput[$property]) && $inputOutput[$property] !== $this->fakePassword) { $inputOutput[$property] = password_hash($inputOutput['password'], PASSWORD_DEFAULT); + } else { + unset($inputOutput[$property]); } return $inputOutput; } diff --git a/tests/Mocks/database.db b/tests/Mocks/database.db index e5c8eff0445c7c27c406bee2a8c1485019c753ce..91f490e419153e0939a3cee935da4d4109482e9d 100644 GIT binary patch delta 173 zcmZo@U}|V!njkHh!oa}50mLv6KT*e+F=bt}9U-`L_%-R(2SYOsi!N|zUz|6|X(#XKbNY~In*AO8D03cs3 ARsaA1 delta 173 zcmZo@U}|V!njkGG%D}+D0mLv6JyFM)QFLR1u{~F6R%u#jg>ObO - - + + @@ -641,7 +641,7 @@ - + @@ -667,52 +667,53 @@ - + - - - + + + - - - + + - - - - - + + + + + - - - - - - + + + + + + + - - + + - + - - - + + + - - - + + + + @@ -843,15 +844,16 @@ - + - - + + + @@ -1312,6 +1314,6 @@ - +