<?php

namespace CfcalSasieSDK\Entity;

use \WsdlToPhp\PackageBase\AbstractStructBase;

/**
 * This class stands for PersonneACharges Entity
 * Meta information extracted from the WSDL
 * - nillable: true
 * - type: tns:PersonneACharges
 * @subpackage Structs
 */
class PersonneACharges extends AbstractStructBase
{
    /**
     * The PersonneACharge
     * Meta information extracted from the WSDL
     * - maxOccurs: unbounded
     * - minOccurs: 0
     * - nillable: true
     * @var \CfcalSasieSDK\Entity\PersonneACharge[]
     */
    public $PersonneACharge;
    /**
     * Constructor method for PersonneACharges
     * @uses PersonneACharges::setPersonneACharge()
     * @param \CfcalSasieSDK\Entity\PersonneACharge[] $personneACharge
     */
    public function __construct(array $personneACharge = array())
    {
        $this
            ->setPersonneACharge($personneACharge);
    }
    /**
     * Get PersonneACharge value
     * An additional test has been added (isset) before returning the property value as
     * this property may have been unset before, due to the fact that this property is
     * removable from the request (nillable=true+minOccurs=0)
     * @return \CfcalSasieSDK\Entity\PersonneACharge[]|null
     */
    public function getPersonneACharge()
    {
        return isset($this->PersonneACharge) ? $this->PersonneACharge : null;
    }
    /**
     * This method is responsible for validating the values passed to the setPersonneACharge method
     * This method is willingly generated in order to preserve the one-line inline validation within the setPersonneACharge method
     * @param array $values
     * @return string A non-empty message if the values does not match the validation rules
     */
    public static function validatePersonneAChargeForArrayConstraintsFromSetPersonneACharge(array $values = array())
    {
        $message = '';
        $invalidValues = [];
        foreach ($values as $personneAChargesPersonneAChargeItem) {
            // validation for constraint: itemType
            if (!$personneAChargesPersonneAChargeItem instanceof \CfcalSasieSDK\Entity\PersonneACharge) {
                $invalidValues[] = is_object($personneAChargesPersonneAChargeItem) ? get_class($personneAChargesPersonneAChargeItem) : sprintf('%s(%s)', gettype($personneAChargesPersonneAChargeItem), var_export($personneAChargesPersonneAChargeItem, true));
            }
        }
        if (!empty($invalidValues)) {
            $message = sprintf('The PersonneACharge property can only contain items of type \CfcalSasieSDK\Entity\PersonneACharge, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues)));
        }
        unset($invalidValues);
        return $message;
    }
    /**
     * Set PersonneACharge value
     * This property is removable from request (nillable=true+minOccurs=0), therefore
     * if the value assigned to this property is null, it is removed from this object
     * @throws \InvalidArgumentException
     * @param \CfcalSasieSDK\Entity\PersonneACharge[] $personneACharge
     * @return \CfcalSasieSDK\Entity\PersonneACharges
     */
    public function setPersonneACharge(array $personneACharge = array())
    {
        // validation for constraint: array
        if ('' !== ($personneAChargeArrayErrorMessage = self::validatePersonneAChargeForArrayConstraintsFromSetPersonneACharge($personneACharge))) {
            throw new \InvalidArgumentException($personneAChargeArrayErrorMessage, __LINE__);
        }
        if (is_null($personneACharge) || (is_array($personneACharge) && empty($personneACharge))) {
            unset($this->PersonneACharge);
        } else {
            $this->PersonneACharge = $personneACharge;
        }
        return $this;
    }
    /**
     * Add item to PersonneACharge value
     * @throws \InvalidArgumentException
     * @param \CfcalSasieSDK\Entity\PersonneACharge $item
     * @return \CfcalSasieSDK\Entity\PersonneACharges
     */
    public function addToPersonneACharge(\CfcalSasieSDK\Entity\PersonneACharge $item)
    {
        // validation for constraint: itemType
        if (!$item instanceof \CfcalSasieSDK\Entity\PersonneACharge) {
            throw new \InvalidArgumentException(sprintf('The PersonneACharge property can only contain items of type \CfcalSasieSDK\Entity\PersonneACharge, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__);
        }
        $this->PersonneACharge[] = $item;
        return $this;
    }
}
