private function validate()
    {
        if (!array_key_exists('type', $this->properties)) {
            throw new StatusException(sprintf('Key %s in %s missing', 'type', __CLASS__), 100, null);
        }

        $type = $this->properties['type'];

        // the type specified must be valid
        if (!in_array($this->properties['type'], $this->types)) {
            throw new StatusException('The type specified is invalid', 100, null);
        }

        switch ($type) {
            case StatusInterface::TYPE_INITIAL:
            case StatusInterface::TYPE_EXCEPTION:
                $mandatoryKeys = ['name'];
                break;

            default:
                $mandatoryKeys = ['name', 'transitions_from', 'transitions_to'];
                break;
        }

        foreach ($mandatoryKeys as $key) {
            if (!array_key_exists($key, $this->properties)) {
                throw new StatusException(sprintf('Key %s in %s missing', $key, __CLASS__), 100, null);
            }
        }

        if (StatusInterface::TYPE_INITIAL != $type && StatusInterface::TYPE_EXCEPTION != $type) {
            $keysMustBeArray = ['transitions_from', 'transitions_to'];
            foreach ($keysMustBeArray as $key) {
                if (!is_array($this->properties[$key])) {
                    throw new StatusException(sprintf('Key %s is not an array', $key), 100, null);
                }
            }
        }
    }
private function validate()
    {
        if (!array_key_exists('type', $this->properties)) {
            throw new StatusException(sprintf('Key %s in %s missing', 'type', __CLASS__), 100, null);
        }

        $type = $this->properties['type'];

        // the type specified must be valid
        if (!in_array($this->properties['type'], $this->types)) {
            throw new StatusException('The type specified is invalid', 100, null);
        }

        switch ($type) {
            case StatusInterface::TYPE_INITIAL:
            case StatusInterface::TYPE_EXCEPTION:
                $mandatoryKeys = ['name'];
                break;

            default:
                $mandatoryKeys = ['name', 'transitions_from', 'transitions_to'];
                break;
        }

        foreach ($mandatoryKeys as $key) {
            if (!array_key_exists($key, $this->properties)) {
                throw new StatusException(sprintf('Key %s in %s missing', $key, __CLASS__), 100, null);
            }
        }

        if (StatusInterface::TYPE_INITIAL != $type && StatusInterface::TYPE_EXCEPTION != $type) {
            $keysMustBeArray = ['transitions_from', 'transitions_to'];
            foreach ($keysMustBeArray as $key) {
                if (!is_array($this->properties[$key])) {
                    throw new StatusException(sprintf('Key %s is not an array', $key), 100, null);
                }
            }
        }
    }
private function validate ( ) { if ( ! array_key_exists ( 'type' , $ this -> properties ) ) { throw new StatusException ( sprintf ( 'Key %s in %s missing' , 'type' , __CLASS__ ) , 100 , null ) ; } $ type = $ this -> properties [ 'type' ] ; // the type specified must be valid if ( ! in_array ( $ this -> properties [ 'type' ] , $ this -> types ) ) { throw new StatusException ( 'The type specified is invalid' , 100 , null ) ; } switch ( $ type ) { case StatusInterface :: TYPE_INITIAL : case StatusInterface :: TYPE_EXCEPTION : $ mandatoryKeys = [ 'name' ] ; break ; default : $ mandatoryKeys = [ 'name' , 'transitions_from' , 'transitions_to' ] ; break ; } foreach ( $ mandatoryKeys as $ key ) { if ( ! array_key_exists ( $ key , $ this -> properties ) ) { throw new StatusException ( sprintf ( 'Key %s in %s missing' , $ key , __CLASS__ ) , 100 , null ) ; } } if ( StatusInterface :: TYPE_INITIAL != $ type && StatusInterface :: TYPE_EXCEPTION != $ type ) { $ keysMustBeArray = [ 'transitions_from' , 'transitions_to' ] ; foreach ( $ keysMustBeArray as $ key ) { if ( ! is_array ( $ this -> properties [ $ key ] ) ) { throw new StatusException ( sprintf ( 'Key %s is not an array' , $ key ) , 100 , null ) ; } } } }
Validate all required properties on initialization.

@throws \Mothership\StateMachine\Exception\StatusException
Validate all required properties on initialization .