<?php

    if ( ! defined( 'ABSPATH' ) ) exit;

    require_once "DigitalSignage4_AutomatisationEntity.php";
    require_once "DigitalSignage4_ForfaitEntity.php";
    require_once "DigitalSignage4_APIResponseEntity.php";
    require_once "DigitalSignage4_CompteEntity.php";
    require_once "DigitalSignage4_DemandeEntity.php";
    require_once "DigitalSignage4_GabaritEntity.php";
    require_once "DigitalSignage4_PlaylistEntity.php";
	
    class DigitalSignage4_Entity
    {
        /**
         * @param $datas
         *
         * @return DigitalSignage4_Entity $this
         * @throws Exception
         */
        public function hydrate($datas)
        {
            foreach ($datas as $attribut => $value) {
                $method = 'set' . str_replace(' ', '', ucwords(str_replace('_', ' ', $attribut)));

                if (is_callable(array( $this, $method ))) {
                    if (gettype($value)=="string") {
                        $value =stripslashes($value);
                    }
                    $this->$method($value);
                }
            }

            return $this;
        }
    }
