PHP Classes

File: src/Traits/HasAttributesTrait.php

Recommend this page to a friend!
  Classes of Derek McLean   HTML Forms   src/Traits/HasAttributesTrait.php   Download  
File: src/Traits/HasAttributesTrait.php
Role: Class source
Content type: text/plain
Description: Class source
Class: HTML Forms
Generate and validate submitted HTML forms
Author: By
Last change:
Date: 6 years ago
Size: 907 bytes
 

Contents

Class file image Download
<?php
/**
 * User: delboy1978uk
 * Date: 04/12/2016
 * Time: 15:01
 */

namespace Del\Form\Traits;


trait
HasAttributesTrait
{
   
/** @var array $attributes */
   
private $attributes = [];

   
/**
     * @param $key
     * @return mixed|string
     */
   
public function getAttribute($key)
    {
        return isset(
$this->attributes[$key]) ? $this->attributes[$key] : null;
    }

   
/**
     * @param $key
     * @param $value
     * @return $this
     */
   
public function setAttribute($key, $value)
    {
       
$this->attributes[$key] = $value;
        return
$this;
    }

   
/**
     * @param array $attributes
     * @return $this
     */
   
public function setAttributes(array $attributes)
    {
       
$this->attributes = $attributes;
        return
$this;
    }

   
/**
     * @return array
     */
   
public function getAttributes()
    {
        return
$this->attributes;
    }
}