From 612b7ba307d9b8c47ba8e2d1555d06379459a76a Mon Sep 17 00:00:00 2001 From: "N@thix86" Date: Tue, 17 Jan 2017 02:39:38 +0800 Subject: [PATCH] Improved code quality --- Element.php | 2 +- HtmlElement.php | 10 +++------- HtmlElementInterface.php | 2 +- LICENSE | 2 +- README.md | 7 +++++-- phpunit.xml.dist | 2 +- 6 files changed, 12 insertions(+), 13 deletions(-) diff --git a/Element.php b/Element.php index 30b99a5..3729e87 100644 --- a/Element.php +++ b/Element.php @@ -61,7 +61,7 @@ public function getType() */ public function setText($text = null) { - if(null != $text){ + if(null !== $text){ $this->text = $text; } diff --git a/HtmlElement.php b/HtmlElement.php index e0143e9..102234f 100644 --- a/HtmlElement.php +++ b/HtmlElement.php @@ -240,7 +240,7 @@ public function load($name, array $parameters = array(), array $attributes = arr /** * {@inheritdoc} */ - static public function create($type = null, $text = null, array $attributes = array(), array $children = array()) + public static function create($type = null, $text = null, array $attributes = array(), array $children = array()) { $htmlElement = new HtmlElement(); @@ -266,28 +266,23 @@ static public function create($type = null, $text = null, array $attributes = ar * * @throws InvalidArgumentsNumberException If the arguments length is more than 3 */ - static public function __callStatic($type, $arguments) + public static function __callStatic($type, $arguments) { switch(count($arguments)){ case 0: return self::create($type); - break; case 1: return self::create($type, $arguments[0]); - break; case 2: return self::create($type, $arguments[0], $arguments[1]); - break; case 3: return self::create($type, $arguments[0], $arguments[1], $arguments[2]); - break; default: throw new InvalidArgumentsNumberException(sprintf( 'Maximum numbers of arguments is %d, [%d] given.', 3, count($arguments) )); - break; } } @@ -393,6 +388,7 @@ private function getInstance($name, array $parameters, $mainCall = false) private function resolveElement($name, array $parameters, $mainCall = false) { $getCurrent = true; + $current = array(); if(is_array($name)){ $current = $name; diff --git a/HtmlElementInterface.php b/HtmlElementInterface.php index 5f9f1df..efd3941 100644 --- a/HtmlElementInterface.php +++ b/HtmlElementInterface.php @@ -14,7 +14,7 @@ interface HtmlElementInterface * * @return ElementInterface */ - static public function create($type = null, $text = null, array $attributes = array(), array $children = array()); + public static function create($type = null, $text = null, array $attributes = array(), array $children = array()); /** * Load a html element. diff --git a/LICENSE b/LICENSE index c622c21..2c38d5e 100644 --- a/LICENSE +++ b/LICENSE @@ -16,4 +16,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +SOFTWARE. diff --git a/README.md b/README.md index 03f8d70..9b1eda3 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # [PHP] Easy Html Element -An easy way to create simple or complex html elements in PHP. - +[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE) +[![Build Status](https://travis-ci.org/natepage/easy-html-element.svg?branch=master)](https://travis-ci.org/natepage/easy-html-element) +[![SensioLabs Insight](https://img.shields.io/sensiolabs/i/1ca37d08-6889-4280-aa4c-5739bf2be48a.svg)](https://insight.sensiolabs.com/projects/1ca37d08-6889-4280-aa4c-5739bf2be48a) +[![Quality Score](https://img.shields.io/scrutinizer/g/natepage/easy-html-element.svg)](https://scrutinizer-ci.com/g/natepage/easy-html-element) +An easy way to create simple or complex html elements in PHP. diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 9c6a9bd..6eaf419 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -20,4 +20,4 @@ - \ No newline at end of file +