Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:sizuhiko/hexpress into develop
Browse files Browse the repository at this point in the history
Conflicts:
	src/Hexpress/Many.php
  • Loading branch information
sizuhiko committed May 29, 2016
2 parents d17b34f + 07d9984 commit 26252fe
Show file tree
Hide file tree
Showing 16 changed files with 38 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ before_script:

script:
- sh -c "if [ '$DEFAULT' = '1' ]; then phpunit --stderr; fi"
- sh -c "if [ '$PHPCS' = '1' ]; then vendor/bin/phpcs -p --extensions=php --standard=PSR2 ./src; fi"
- sh -c "if [ '$PHPCS' = '1' ]; then vendor/bin/phpcs -p --extensions=php --standard=ruleset.xml ./src; fi"
- sh -c "if [ '$COVERALLS' = '1' ]; then phpunit --stderr --coverage-clover build/logs/clover.xml; fi"

after_script:
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[![Build Status](https://travis-ci.org/sizuhiko/hexpress.svg?branch=master)](https://travis-ci.org/sizuhiko/hexpress) [![Coverage Status](https://coveralls.io/repos/sizuhiko/hexpress/badge.svg?branch=master&service=github)](https://coveralls.io/github/sizuhiko/hexpress?branch=master) [![Latest Stable Version](https://poser.pugx.org/sizuhiko/hexpress/v/stable)](https://packagist.org/packages/sizuhiko/hexpress) [![Total Downloads](https://poser.pugx.org/sizuhiko/hexpress/downloads)](https://packagist.org/packages/sizuhiko/hexpress) [![Latest Unstable Version](https://poser.pugx.org/sizuhiko/hexpress/v/unstable)](https://packagist.org/packages/sizuhiko/hexpress) [![License](https://poser.pugx.org/sizuhiko/hexpress/license)](https://packagist.org/packages/sizuhiko/hexpress)

# hexpress
hexpress is a PHP library that human way to define regular expressions

Expand Down
16 changes: 16 additions & 0 deletions ruleset.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0"?>
<ruleset name="My Standards">
<description>My Coding Standards enforcement rule set for PHP_CodeSniffer</description>
<rule ref="PSR2">
<exclude name="PSR1.Classes.ClassDeclaration.MultipleClasses" />
<exclude name="Squiz.Functions.MultiLineFunctionDeclaration.ContentAfterBrace" />
<exclude name="Squiz.WhiteSpace.ScopeClosingBrace.ContentBefore" />
<exclude name="Generic.Formatting.DisallowMultipleStatements.SameLine" />
</rule>
<rule ref="Generic.Files.LineLength">
<properties>
<property name="lineLimit" value="140"/>
<property name="absoluteLineLimit" value="160"/>
</properties>
</rule>
</ruleset>
11 changes: 3 additions & 8 deletions src/Hexpress.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,29 +219,24 @@ private function add($hex)
return $this;
}

private function add_value($hex, $value)
private function addValue($hex, $value)
{
$this->add(new $hex(is_callable($value) ? new self($value) : $value));

return $this;
}

private function add_nested($hex, $value)
private function addNested($hex, $value)
{
$this->add(new $hex($value));

return $this;
}

private function add_values($hex, $value, $option)
private function addValues($hex, $value, $option)
{
$this->add(new $hex(is_callable($value) ? new self($value) : $value, $option));

return $this;
}

private function pop_value()
{
return array_pop($this->expressions);
}
}
2 changes: 1 addition & 1 deletion src/Hexpress/Limit.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ trait Limit
{
public function limit($value, $min, $max = 0)
{
return $this->add_values(LimitValue::class, $value, [$min, $max]);
return $this->addValues(LimitValue::class, $value, [$min, $max]);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Hexpress/Many.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public function many($value = null, $minimum = 1)
if($minimum > 1) {
return $this->limit($value, $minimum);
}
return $this->add_values(ManyValue::class, $value, $minimum);
return $this->addValues(ManyValue::class, $value, $minimum);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/Hexpress/Nested.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ public function delimiter()

public function hexpression()
{
return $this->joinable() ? $this->join_hexpression() : $this->hexpression;
return $this->joinable() ? $this->joinHexpression() : $this->hexpression;
}

public function __toString()
{
return $this->wrapping($this->hexpression());
}

private function join_hexpression()
private function joinHexpression()
{
return implode($this->delimiter(), $this->hexpression);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Hexpress/Nested/Find.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public function find($value = null, $named = false)
{
$param = compact('value', 'named');

return is_callable($value) ? $this->add_nested(FindValue::class, $param) : $this->add_value(FindValue::class, $param);
return is_callable($value) ? $this->addNested(FindValue::class, $param) : $this->addValue(FindValue::class, $param);
}
public function capture($value = null)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Hexpress/Nested/Matching.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ trait Matching
{
public function matching($callback)
{
return $this->add_nested(MatchingValue::class, $callback);
return $this->addNested(MatchingValue::class, $callback);
}
public function like($callback)
{
Expand All @@ -32,7 +32,7 @@ public function __construct($callback)
$this->close = ']';
}

public function join_hexpression()
public function joinHexpression()
{
return implode('', array_map(function ($value) {
return $this->escape($value);
Expand Down
2 changes: 1 addition & 1 deletion src/Hexpress/One.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ trait One
{
public function one($value = null)
{
return $this->add_value(OneValue::class, $value);
return $this->addValue(OneValue::class, $value);
}
public function maybe($value = null)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Hexpress/Value/Ending.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ trait Ending
{
public function ending($value = null)
{
return $this->add_value(EndingValue::class, $value);
return $this->addValue(EndingValue::class, $value);
}
public function end($value = null)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Hexpress/Value/Except.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ trait Except
{
public function except($value)
{
return $this->add_value(ExceptValue::class, $value);
return $this->addValue(ExceptValue::class, $value);
}
public function excluding($value)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Hexpress/Value/Starting.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ trait Starting
{
public function starting($value = null)
{
return $this->add_value(StartingValue::class, $value);
return $this->addValue(StartingValue::class, $value);
}
public function begins($value)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Hexpress/Value/With.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ trait With
{
public function with($value)
{
return $this->add_value(WithValue::class, $value);
return $this->addValue(WithValue::class, $value);
}
public function has($value)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Hexpress/Values/Either.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ trait Either
{
public function either($values)
{
return $this->add_value(EitherValue::class, $values);
return $this->addValue(EitherValue::class, $values);
}
public function anyOf($values)
{
Expand Down
6 changes: 3 additions & 3 deletions src/Hexpress/Values/Range.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@ public function lower($value = false)
{
$value = empty($value) ? range('a', 'z') : $value;

return $this->add_value(RangeValue::class, $value);
return $this->addValue(RangeValue::class, $value);
}

public function upper($value = false)
{
$value = empty($value) ? range('A', 'Z') : $value;

return $this->add_value(RangeValue::class, $value);
return $this->addValue(RangeValue::class, $value);
}

public function number($value = false)
{
$value = empty($value) ? range('0', '9') : $value;

return $this->add_value(RangeValue::class, $value);
return $this->addValue(RangeValue::class, $value);
}
}

Expand Down

0 comments on commit 26252fe

Please sign in to comment.