Skip to content

Commit

Permalink
Merge branch 'release/1.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
xavismeh committed Jun 6, 2019
2 parents 109b80b + 3beef84 commit 4c94581
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
10 changes: 2 additions & 8 deletions src/EmailAddressTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,10 @@ public function transformUnique($input): Address
$input = current($input);

if (\is_string($input)) {
return \is_int($key) ? new Address($input) : new NamedAddress($input, $key);
return \is_int($key) ? new Address($input) : new NamedAddress($key, $input);
}

if ($input instanceof NamedAddress) {
return $input;
}

// If a string has been provided as the key, we want to convert the Address object into a NamedAddress instance
// unless it is already one
return \is_int($key) ? $input : new NamedAddress($input->getAddress(), $key);
return $input;
}

/**
Expand Down
12 changes: 6 additions & 6 deletions tests/EmailAddressTransformerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,26 @@ public function dataProviderTransformUnique(): array
],
// 3. An à-la swiftmailer array with one entry
[
['Testing is great' => '[email protected]'],
['[email protected]' => 'Testing is great'],
new NamedAddress('[email protected]', 'Testing is great')
],
// 4. An array of strings
[
['[email protected]', '[email protected]'],
new Address('[email protected]')
],
// 4. An array containing an Address object as first value **SHOULD BE** overwritten.
// 4. An array containing an Address object as first value should remain unchanged
[
[
'Passing Master' => new Address('[email protected]'),
'[email protected]' => new Address('[email protected]'),
'[email protected]'
],
new NamedAddress('[email protected]', 'Passing Master')
new Address('[email protected]')
],
// 5. An array containing a NamedAddress object as first value **SHOULD NOT BE** overwritten.
// 5. An array containing a NamedAddress object as first value should remain unchanged
[
[
'Ignored Senor' => new NamedAddress('[email protected]', 'Toto'),
new NamedAddress('[email protected]', 'Toto'),
'[email protected]'
],
new NamedAddress('[email protected]', 'Toto')
Expand Down

0 comments on commit 4c94581

Please sign in to comment.