Swat/SwatUI.php
private function checkParsedObject(
        SwatUIObject $parsed_object,
        $element_name
    ) {
        if ($element_name == 'widget') {
            if (
                class_exists('SwatWidget') &&
                $parsed_object instanceof SwatWidget &&
                $parsed_object->id !== null
            ) {
                // make sure id is unique
                if (isset($this->widgets[$parsed_object->id])) {
                    throw new SwatDuplicateIdException(
                        "A widget with an id of '{$parsed_object->id}' " .
                            'already exists.',
                        0,
                        $parsed_object->id
                    );
                }
            } elseif (
                !class_exists('SwatWidget') ||
                !$parsed_object instanceof SwatWidget
            ) {
                $class_name = get_class($parsed_object);

                throw new SwatInvalidClassException(
                    "'{$class_name}' is defined in a widget element but is " .
                        'not an instance of SwatWidget.',
                    0,
                    $parsed_object
                );
            }
        } elseif ($element_name == 'object') {
            if (
                class_exists('SwatWidget') &&
                $parsed_object instanceof SwatWidget
            ) {
                $class_name = get_class($parsed_object);

                throw new SwatInvalidClassException(
                    "'{$class_name}' is defined in an object element but is " .
                        'and instance of SwatWidget and should be defined in a ' .
                        'widget element.',
                    0,
                    $parsed_object
                );
            }
        }
    }
private function checkParsedObject(
        SwatUIObject $parsed_object,
        $element_name
    ) {
        if ($element_name == 'widget') {
            if (
                class_exists('SwatWidget') &&
                $parsed_object instanceof SwatWidget &&
                $parsed_object->id !== null
            ) {
                // make sure id is unique
                if (isset($this->widgets[$parsed_object->id])) {
                    throw new SwatDuplicateIdException(
                        "A widget with an id of '{$parsed_object->id}' " .
                            'already exists.',
                        0,
                        $parsed_object->id
                    );
                }
            } elseif (
                !class_exists('SwatWidget') ||
                !$parsed_object instanceof SwatWidget
            ) {
                $class_name = get_class($parsed_object);

                throw new SwatInvalidClassException(
                    "'{$class_name}' is defined in a widget element but is " .
                        'not an instance of SwatWidget.',
                    0,
                    $parsed_object
                );
            }
        } elseif ($element_name == 'object') {
            if (
                class_exists('SwatWidget') &&
                $parsed_object instanceof SwatWidget
            ) {
                $class_name = get_class($parsed_object);

                throw new SwatInvalidClassException(
                    "'{$class_name}' is defined in an object element but is " .
                        'and instance of SwatWidget and should be defined in a ' .
                        'widget element.',
                    0,
                    $parsed_object
                );
            }
        }
    }
private function checkParsedObject ( SwatUIObject $ parsed_object , $ element_name ) { if ( $ element_name == 'widget' ) { if ( class_exists ( 'SwatWidget' ) && $ parsed_object instanceof SwatWidget && $ parsed_object -> id !== null ) { // make sure id is unique if ( isset ( $ this -> widgets [ $ parsed_object -> id ] ) ) { throw new SwatDuplicateIdException ( "A widget with an id of '{$parsed_object->id}' " . 'already exists.' , 0 , $ parsed_object -> id ) ; } } elseif ( ! class_exists ( 'SwatWidget' ) || ! $ parsed_object instanceof SwatWidget ) { $ class_name = get_class ( $ parsed_object ) ; throw new SwatInvalidClassException ( "'{$class_name}' is defined in a widget element but is " . 'not an instance of SwatWidget.' , 0 , $ parsed_object ) ; } } elseif ( $ element_name == 'object' ) { if ( class_exists ( 'SwatWidget' ) && $ parsed_object instanceof SwatWidget ) { $ class_name = get_class ( $ parsed_object ) ; throw new SwatInvalidClassException ( "'{$class_name}' is defined in an object element but is " . 'and instance of SwatWidget and should be defined in a ' . 'widget element.' , 0 , $ parsed_object ) ; } } }
Does some error checking on a parsed object

Checks to make sure widget objects are created from widget elements
and other objects are created from object elements.

@param SwatUIObject $parsed_object an object that has been parsed from
SwatML.
@param string $element_name the name of the XML element node the object
was parsed from.

@throws SwatDuplicateIdException, SwatInvalidClassException
Does some error checking on a parsed object