-
-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ip validator #21
Ip validator #21
Conversation
shoman4eg
commented
May 22, 2019
Q | A |
---|---|
Is bugfix? | yes |
New feature? | no |
Breaks BC? | yes |
Tests pass? | yes? |
Fixed issues |
* | ||
* @return Ip | ||
*/ | ||
public function useSubnet($subnet): self |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd introduce two methods instead:
- requireSubnet
- optionalSubnet
Also internally it makes sense to introduce three private constants instead of having true/false/null as magic values.
* | ||
* @return Ip | ||
*/ | ||
public function useIpv4($ipv4): self |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public function useIpv4($ipv4): self | |
public function allowIpv4(bool $value): self |
* | ||
* @return Ip | ||
*/ | ||
public function useIpv6(bool $ipv6): self |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public function useIpv6(bool $ipv6): self | |
public function allowIpv6(bool $value): self |
{ | ||
$result = new Result(); | ||
$this->ipv6 = $ipv6; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$this->ipv6 = $ipv6; | |
$this->allowIpv6 = $value; |
*/ | ||
public function useIpv4($ipv4): self | ||
{ | ||
$this->ipv4 = $ipv4; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$this->ipv4 = $ipv4; | |
$this->allowIpv4 = $value; |
*/ | ||
public function useSubnet($subnet): self | ||
{ | ||
$this->subnet = $subnet; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$this->subnet = $subnet; | |
$this->subnetStrategy = $subnet; |
* | ||
* @return Ip | ||
*/ | ||
public function useNegation(bool $negation): self |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public function useNegation(bool $negation): self | |
public function allowNegation(bool $value): self |
*/ | ||
public function useNegation(bool $negation): self | ||
{ | ||
$this->negation = $negation; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$this->negation = $negation; | |
$this->allowNegation = $value; |
} | ||
|
||
return $result; | ||
return $this->validateSubnet($value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It makes little sense to have a separate method in this case.
$validator = new Ip(['ranges' => $range]); | ||
$this->assertEquals($expectedRange, $validator->ranges); | ||
$validator = new Ip(); | ||
$validator->setRanges($range); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$validator->setRanges($range); | |
$validator->ranges($range); |
Closable via #32 |