PHP Classes
elePHPant
Icontem

File: docs/files/src/SVGCreator/Elements/Rect.php.txt

Recommend this page to a friend!
  Classes of Tio  >  PHP SVG Creator  >  docs/files/src/SVGCreator/Elements/Rect.php.txt  >  Download  
File: docs/files/src/SVGCreator/Elements/Rect.php.txt
Role: Documentation
Content type: text/plain
Description: Documentation
Class: PHP SVG Creator
Generate SVG chart documents
Author: By
Last change:
Date: 2 years ago
Size: 881 bytes
 

Contents

Class file image Download
<?php

/**
 * Rect Class
 *
 * @package    SVGCreator
 * @subpackage Elements
 * @author     Sérgio Diniz
 * @version    1.0
 */

namespace SVGCreator\Elements;

class Rect extends \SVGCreator\Element {

    const TYPE = \SVGCreator\Element::RECT;

    static protected $mandatoryFields = array(
    									'width',
    									'height',
    									'x',
    									'y'
    								);

    protected function validateElementValues() {
    	// Iterate over all fields
    	foreach ( self::$mandatoryFields as $field ) {
    		// If the field does not exist then exit with exception
    		if ( array_key_exists($field, $this->attributes) ) {
    			$value = (int) $this->attributes[$field];
    			if ( $value < 0 ) {
    				throw new \SVGCreator\SVGException("The ".$field." value is lesser than 0, in element ".self::TYPE, 1);
    			}
    		}
    	}

		return true;
	}

}