Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
norberttech committed Feb 4, 2018
1 parent df73c82 commit ae1bb37
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 51 deletions.
14 changes: 1 addition & 13 deletions src/Matcher/Pattern/Expander/Contains.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,12 @@ final class Contains implements PatternExpander
{
const NAME = 'contains';

/**
* @var null|string
*/
private $error;

/**
* @var
*/
private $string;

/**
* @var bool
*/
private $ignoreCase;

/**
* {@inheritdoc}
*/
public static function is(string $name) : bool
{
return self::NAME === $name;
Expand All @@ -48,7 +36,7 @@ public function match($value) : bool
}

$contains = $this->ignoreCase
? \mb_strpos(\mb_strtolower($value), \mb_strtolower($this->string))
? \mb_stripos($value, $this->string)
: \mb_strpos($value, $this->string);

if ($contains === false) {
Expand Down
2 changes: 1 addition & 1 deletion src/Matcher/Pattern/Expander/EndsWith.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function getError()
return $this->error;
}

protected function matchValue(string $value) : bool
private function matchValue(string $value) : bool
{
return $this->ignoreCase
? \mb_substr(\mb_strtolower($value), -\mb_strlen(\mb_strtolower($this->stringEnding))) === \mb_strtolower($this->stringEnding)
Expand Down
2 changes: 1 addition & 1 deletion src/Matcher/Pattern/Expander/IsDateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function getError()
return $this->error;
}

protected function matchValue(string $value) : bool
private function matchValue(string $value) : bool
{
try {
new \DateTime($value);
Expand Down
2 changes: 1 addition & 1 deletion src/Matcher/Pattern/Expander/IsEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function getError()
return $this->error;
}

protected function matchValue(string $value) : bool
private function matchValue(string $value) : bool
{
try {
return false !== \filter_var($value, FILTER_VALIDATE_EMAIL);
Expand Down
2 changes: 1 addition & 1 deletion src/Matcher/Pattern/Expander/IsUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function getError()
return $this->error;
}

protected function matchValue(string $value) : bool
private function matchValue(string $value) : bool
{
try {
return false !== \filter_var($value, FILTER_VALIDATE_URL);
Expand Down
4 changes: 2 additions & 2 deletions src/Matcher/Pattern/Expander/OneOf.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ final class OneOf implements PatternExpander
/**
* @var PatternExpander[]
*/
protected $expanders;
private $expanders;

protected $error;
private $error;

public function __construct()
{
Expand Down
30 changes: 0 additions & 30 deletions src/Matcher/Pattern/Expander/Repeat.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,19 @@ final class Repeat implements PatternExpander
{
const NAME = 'repeat';

/**
* @var null|string
*/
private $error;

/**
* @var string
*/
private $pattern;

/**
* @var bool
*/
private $isStrict;

/**
* @var bool
*/
private $isScalar;

/**
* {@inheritdoc}
*/
public static function is(string $name) : bool
{
return self::NAME === $name;
}

/**
* @param $value
*/
public function __construct(string $pattern, bool $isStrict = true)
{
if (!\is_string($pattern)) {
Expand All @@ -62,10 +44,6 @@ public function __construct(string $pattern, bool $isStrict = true)
}
}

/**
* @param $values
* @return bool
*/
public function match($values) : bool
{
if (!\is_array($values)) {
Expand All @@ -83,19 +61,11 @@ public function match($values) : bool
return $this->matchJson($values, $matcher);
}

/**
* @return string|null
*/
public function getError()
{
return $this->error;
}

/**
* @param array $values
* @param Matcher $matcher
* @return bool
*/
private function matchScalar(array $values, Matcher $matcher) : bool
{
foreach ($values as $index => $value) {
Expand Down
4 changes: 2 additions & 2 deletions src/Matcher/Pattern/Expander/StartsWith.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ public function getError()
return $this->error;
}

protected function matchValue(string $value) : bool
private function matchValue(string $value) : bool
{
return $this->ignoreCase
? \mb_strpos(\mb_strtolower($value), \mb_strtolower($this->stringBeginning)) !== 0
? \mb_stripos($value, $this->stringBeginning) !== 0
: \mb_strpos($value, $this->stringBeginning) !== 0;
}
}

0 comments on commit ae1bb37

Please sign in to comment.