Skip to content

add support for converting to null#53

Merged
ddeboer merged 1 commit intoportphp:masterfrom
bendavies:value-mapping-converter-null
Aug 31, 2017
Merged

add support for converting to null#53
ddeboer merged 1 commit intoportphp:masterfrom
bendavies:value-mapping-converter-null

Conversation

@bendavies
Copy link
Copy Markdown
Contributor

@bendavies bendavies commented Aug 25, 2017

MappingValueConverter didn't support converting a value to null, which this PR addresses.

@bendavies bendavies force-pushed the value-mapping-converter-null branch from 33558bf to b11562d Compare August 25, 2017 20:07
public function __invoke($input)
{
if (!isset($this->mapping[$input])) {
if (!\array_key_exists($input, $this->mapping)) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

array_key_exists is slower than isset, so can you change this to:

if (isset(…) || array_key_exists(…)) {
    return …
}

throw

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hah, Premature Optimization?

You're the boss!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is done

@bendavies bendavies force-pushed the value-mapping-converter-null branch from b11562d to 315d58e Compare August 31, 2017 09:21
@ddeboer ddeboer merged commit e8d3a37 into portphp:master Aug 31, 2017
@ddeboer
Copy link
Copy Markdown
Member

ddeboer commented Aug 31, 2017

Thanks!

@bendavies
Copy link
Copy Markdown
Contributor Author

thanks for the merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants