Skip to content

Commit

Permalink
Merge pull request #130 from ergebnis/fix/ternary
Browse files Browse the repository at this point in the history
Fix: Avoid ternary statement
  • Loading branch information
localheinz authored Mar 30, 2020
2 parents 117d686 + 4e3ca77 commit c99e683
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@
<code>$fieldDefinitions</code>
<code>$fieldOverrides</code>
</MixedArgumentTypeCoercion>
<MixedAssignment occurrences="5">
<MixedAssignment occurrences="6">
<code>$defaultFieldValue</code>
<code>$fieldValues[$fieldName]</code>
<code>$fieldValues[$fieldName]</code>
<code>$fieldValue</code>
<code>$inversedBy</code>
<code>$collection</code>
Expand Down
10 changes: 7 additions & 3 deletions src/FixtureFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,13 @@ public function get(string $className, array $fieldOverrides = [])
$fieldValues = [];

foreach ($entityDefinition->fieldDefinitions() as $fieldName => $fieldDefinition) {
$fieldValues[$fieldName] = \array_key_exists($fieldName, $fieldOverrides)
? $fieldOverrides[$fieldName]
: $fieldDefinition($this);
if (\array_key_exists($fieldName, $fieldOverrides)) {
$fieldValues[$fieldName] = $fieldOverrides[$fieldName];

continue;
}

$fieldValues[$fieldName] = $fieldDefinition($this);
}

foreach ($fieldValues as $fieldName => $fieldValue) {
Expand Down

0 comments on commit c99e683

Please sign in to comment.