# WHOOP
## What?! HTML, as Object-Oriented PHP?

Library providing for HTML elements as objects in PHP. Attributes (including data attributes),
properties, and classes are all supported. As are parent-child relationships of elements.

## Create an Element
HTML/PHP objects can be created with the `::create()` method of the element's PHP entity (identified by)
tag name. Every element can be created with two optional arguments: content, and attributes.

`$link = A::create('Link Text', [ 'href' => 'https://www.tamu.edu' ]);`

## Working with Elements
### Attributes/Properties
Any attribute can be added to an element simply. **All attributes and properties
are automatically escaped appropriately when rendered.**

`$link->setAttribute('attribute', 'attributeValue');`

An attribute can be modified with the same method.

`$link->setAttribute('attribute', 'newAttributeValue');`

An attribute can also be removed.

`$link->unsetAttribute('attribute');`

### IDs
The ID is a special attribute. Setting the ID of an element is simple...

`$link->setId('link-id');`

### Classes
Every element has a "classlist", similar to Javascript. Classes can be added like this...

`$link->addClass('link-class remove-this-class');`

...and removed (one at a time) like this...

`$link->removeClass('remove-this-class');`

### Data Attributes
Every element has a "dataset", again similar to Javascript. The "data-" prefix 
of data attributes is automatically added to data keys. Data can be added like this...

`$link->setDataValue('key', 'data-value');`

A data attribute can be modified with the same method

`$link->setDataValue('key', 'new-data-value');`

A data attribute can also be removed.

`$link->unsetDataValue('key');`

## Working with Content
Content - including other elements - can be added to elements.

### Prepending Content
`$link->prepend('<strong>ATTENTION!</strong>`);`

### Appending Elements

`
    $icon = Span::create('', ['class' => 'icon']);
    $link->appendElement($icon);
`

## Rendering Elements
Every element is "stringable", which happens automatically when treating the element like a string.

### Output Element
`echo $link;`

### Get the Element's HTML String
`$linkString = (string) $link;`
