dotkernel / dot-mapper

DotKernel mapper pattern implementation
MIT License
2 stars 2 forks source link

Array value is set before being tested #8

Closed bandronic closed 7 years ago

bandronic commented 7 years ago

I think some test code slipped in AbstractDbMapper at line 257:

$options += [
        'atomic' => true
];

if ($options['atomic']) {
...
n3vrax commented 7 years ago

This is one way to set a default value in an array key. The union array operator is similar to a merge, the right-hand side value will be appended. If the key exists in both operands, the left-hand side will be considered and the right-hand side will be ignored.

So, if the $options array coming as a parameter has the key 'atomic' set to a value(true or false), the union operation does nothing.

I does set the default atomic value to true, only if it was not set from the outside, in other words, the key is missing. This way we can omit an if statement