diff --git a/.travis.yml b/.travis.yml index 2f3e9ab..b7d1bac 100755 --- a/.travis.yml +++ b/.travis.yml @@ -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: diff --git a/README.md b/README.md index bf1ba3b..3dbbb60 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/ruleset.xml b/ruleset.xml new file mode 100755 index 0000000..208dd99 --- /dev/null +++ b/ruleset.xml @@ -0,0 +1,16 @@ + + + My Coding Standards enforcement rule set for PHP_CodeSniffer + + + + + + + + + + + + + diff --git a/src/Hexpress.php b/src/Hexpress.php index 06928d5..a8ee0ef 100644 --- a/src/Hexpress.php +++ b/src/Hexpress.php @@ -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); - } } diff --git a/src/Hexpress/Limit.php b/src/Hexpress/Limit.php index 476cce3..262903f 100644 --- a/src/Hexpress/Limit.php +++ b/src/Hexpress/Limit.php @@ -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]); } } diff --git a/src/Hexpress/Many.php b/src/Hexpress/Many.php index 03931a0..5e4e7dd 100644 --- a/src/Hexpress/Many.php +++ b/src/Hexpress/Many.php @@ -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); } } diff --git a/src/Hexpress/Nested.php b/src/Hexpress/Nested.php index b5f3fbf..7fba8cc 100644 --- a/src/Hexpress/Nested.php +++ b/src/Hexpress/Nested.php @@ -13,7 +13,7 @@ public function delimiter() public function hexpression() { - return $this->joinable() ? $this->join_hexpression() : $this->hexpression; + return $this->joinable() ? $this->joinHexpression() : $this->hexpression; } public function __toString() @@ -21,7 +21,7 @@ public function __toString() return $this->wrapping($this->hexpression()); } - private function join_hexpression() + private function joinHexpression() { return implode($this->delimiter(), $this->hexpression); } diff --git a/src/Hexpress/Nested/Find.php b/src/Hexpress/Nested/Find.php index d4d4dbe..0019f20 100644 --- a/src/Hexpress/Nested/Find.php +++ b/src/Hexpress/Nested/Find.php @@ -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) { diff --git a/src/Hexpress/Nested/Matching.php b/src/Hexpress/Nested/Matching.php index ed2fbcf..39b29c8 100644 --- a/src/Hexpress/Nested/Matching.php +++ b/src/Hexpress/Nested/Matching.php @@ -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) { @@ -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); diff --git a/src/Hexpress/One.php b/src/Hexpress/One.php index 789ec13..bdce982 100644 --- a/src/Hexpress/One.php +++ b/src/Hexpress/One.php @@ -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) { diff --git a/src/Hexpress/Value/Ending.php b/src/Hexpress/Value/Ending.php index 9915cfa..2e44124 100644 --- a/src/Hexpress/Value/Ending.php +++ b/src/Hexpress/Value/Ending.php @@ -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) { diff --git a/src/Hexpress/Value/Except.php b/src/Hexpress/Value/Except.php index 75a03e0..54b7640 100644 --- a/src/Hexpress/Value/Except.php +++ b/src/Hexpress/Value/Except.php @@ -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) { diff --git a/src/Hexpress/Value/Starting.php b/src/Hexpress/Value/Starting.php index c7fa53b..53752c8 100644 --- a/src/Hexpress/Value/Starting.php +++ b/src/Hexpress/Value/Starting.php @@ -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) { diff --git a/src/Hexpress/Value/With.php b/src/Hexpress/Value/With.php index 81909b5..9df833a 100644 --- a/src/Hexpress/Value/With.php +++ b/src/Hexpress/Value/With.php @@ -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) { diff --git a/src/Hexpress/Values/Either.php b/src/Hexpress/Values/Either.php index 54acb7e..a6c3447 100644 --- a/src/Hexpress/Values/Either.php +++ b/src/Hexpress/Values/Either.php @@ -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) { diff --git a/src/Hexpress/Values/Range.php b/src/Hexpress/Values/Range.php index 318d3c6..4a82cc2 100644 --- a/src/Hexpress/Values/Range.php +++ b/src/Hexpress/Values/Range.php @@ -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); } }