Crell / EnvMapper

Easily map environment variables into defined classed objects, ready for Dependency Injection.
GNU Lesser General Public License v3.0
83 stars 3 forks source link

Default values that are falsy will not be set #4

Closed SpadXIII closed 1 year ago

SpadXIII commented 1 year ago

I was just checking out this cool little thing and ran into a little issue: when you use falsy default values (empty string, zero, null, false) they won't get set. This is because getDefaultValueFromConstructor returns the actual value which is then implicitly checked in an if-statement.

A solution could be to extract that check into a hasDefaultValueFromConstructor method and let getDefaultValueFromConstructor only get the actual value.

SpadXIII commented 1 year ago

I'm out of time for today, so can't make an actual PR. I can make a PR in a few days though :)

Crell commented 1 year ago

Ah ha! You are correct. Good catch. I'll wait for a PR, or until I am next bored and feel like fixing bugs. :smile: Thanks.