PHP Classes

File: src/org/majkel/tcpdfwarper/generator/ConfigItem.php

Recommend this page to a friend!
  Classes of Michal Kowalik   TCPDF Warper   src/org/majkel/tcpdfwarper/generator/ConfigItem.php   Download  
File: src/org/majkel/tcpdfwarper/generator/ConfigItem.php
Role: Auxiliary script
Content type: text/plain
Description: generator
Class: TCPDF Warper
Create PDF documents using TCPDF fluent interface
Author: By
Last change: Update of src/org/majkel/tcpdfwarper/generator/ConfigItem.php
Date: 11 months ago
Size: 1,241 bytes
 

Contents

Class file image Download
<?php
/**
 * Created by PhpStorm.
 * User: Micha? (majkel) Kowalik <maf.michal@gmail.com>
 * Date: 1/17/2015
 * Time: 20:44
 */

namespace org\majkel\tcpdfwarper\generator;

use
org\majkel\tcpdfwarper\Utils;

/**
 * Class ConfigItem
 * @package org\majkel\tcpdfwarper\generator
 */
class ConfigItem {

   
/** @var string */
   
public $name;
   
/** @var string */
   
public $method;
   
/** @var string */
   
public $className;
   
/** @var ConfigMetaMethod[] */
   
public $metaMethods;
   
/** @var string[] */
   
public $additionalDoc;

   
/**
     * @param $array
     * @return ConfigItem
     * @throws GeneratorException
     */
   
public static function fromArray($array) {
        if (!isset(
$array['method'])) {
            throw new
GeneratorException("Missing `method` key");
        }
       
$obj = new static();
       
$obj->method = $array['method'];
       
$obj->name = isset($array['className']) ? $array['className'] : $array['method'];
       
$obj->className = $obj->name.'Op';
       
$obj->additionalDoc = Utils::getKeyAsArray($array, 'additionalDoc');
       
$obj->metaMethods = array();
        if (isset(
$array['metaMethods']) && is_array($array['metaMethods'])) {
            foreach (
$array['metaMethods'] as $metaMethod) {
               
$obj->metaMethods[] = ConfigMetaMethod::fromArray($metaMethod);
            }
        }
        return
$obj;
    }

}