Skip to content

Commit

Permalink
Improve attribute processing, docs and phpunit configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
dvdheiden committed Jul 26, 2017
1 parent 931d746 commit 195c50f
Show file tree
Hide file tree
Showing 6 changed files with 570 additions and 204 deletions.
150 changes: 149 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,150 @@
/vendor/
# Based on https://github.com/github/gitignore/tree/master/Global

################################################################################
#
# Ignore all dot-files and dot-folders, except .htaccess and .gitignore
#
################################################################################
.*
!/.gitignore
!/.htaccess

################################################################################
#
# JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion
#
################################################################################
*.iml
.idea/

## File-based project format:
*.ipr
*.iws

# Plugin-specific files:

# IntelliJ
/out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties

################################################################################
#
# Netbeans
#
################################################################################

nbproject/
build/
nbbuild/
dist/
nbdist/
nbactions.xml
nb-configuration.xml
.nb-gradle/

################################################################################
#
# Windows OS
#
################################################################################

# Windows image file caches
Thumbs.db
ehthumbs.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msm
*.msp

# Windows shortcuts
*.lnk

################################################################################
#
# Notepad++
#
################################################################################

*.bak

################################################################################
#
# Vagrant
#
################################################################################

.vagrant/

################################################################################
#
# TortoiseGit
#
################################################################################

# Project-level settings
/.tgitconfig

################################################################################
#
# NodeJS
#
################################################################################

# Logs
logs
*.log

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directory
# https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git
node_modules

################################################################################
#
# Composer
#
################################################################################

composer.phar
vendor/

# Commit your application's lock file http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
# composer.lock
28 changes: 21 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# HtmlElement

This package allows you to easily create HTML elements from PHP. It's inspired by [David Walsh's blogpost](https://davidwalsh.name/create-html-elements-php-htmlelement-class) but further improved.
This package allows you to easily create HTML elements from PHP. It's inspired by
[David Walsh's blogpost](https://davidwalsh.name/create-html-elements-php-htmlelement-class) but further improved.

```$php
// Create new html element with attribute name
Expand Down Expand Up @@ -59,20 +60,33 @@ $containerElement->inject($rowElement);

The text and attributes can also be added, which merges with existing text or attributes.

## Methods

* `getTag` or `setTag` to request or change the tag.
* `getAttributes` or `getAttribute(attribute)` to retrieve all attributes with their values or one attributes with its
value
* `setAttributes` or `setAttribute(attribute, value)` to manipulate all attributes or just one.
* `addAttributeValue` adds a value to an attributes.
* `removeAttributes` or `removeAttribute(attribute)` to remove all attributes or just one.
* `removeAttributeValue(attribute, value)` to remove one value from a attribute.
* `getText`, `addText` or `setText` to retrieve, add or set the inner text.
* `inject` to inject a htmlElement into the current htmlElement.
* `generate` generates the htmlElement and returns its string representation.
* `output` echos the result of `generate`.

## Tests

Full code coverage unit tests are available in the `tests` folder. Run via phpunit:

`vendor\bin\phpunit tests`

Or if you are interested in the (html) coverage report:
`vendor\bin\phpunit`

`vendor\bin\phpunit tests --coverage-html report --whitelist src`
By default a coverage report will be generated in the `build/coverage` folder.

## Contribution

Any contribution is welcome, but it should be fully tested, meet the PSR-2 standard and please create one pull request per feature. In exchange you will be credited as contributor on this page.
Any contribution is welcome, but it should be fully tested, meet the PSR-2 standard and please create one pull request
per feature. In exchange you will be credited as contributor on this page.

## License

This package is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)
This package is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)
Loading

0 comments on commit 195c50f

Please sign in to comment.