src/ServiceBus/Models/RuleDescription.php
public static function create($ruleDescriptionXml)
    {
        $ruleDescription = new self();
        $root = simplexml_load_string(
            $ruleDescriptionXml
        );
        $ruleDescriptionArray = (array) $root;
        if (array_key_exists('Filter', $ruleDescriptionArray)) {
            $filterItem = $ruleDescriptionArray['Filter'];
            $filterAttributes = $filterItem->attributes('i', true);
            $filterItemArray = (array) $filterItem;
            $filterType = (string) $filterAttributes['type'];
            $filter = null;
            switch ($filterType) {
            case 'TrueFilter':
                $filter = new TrueFilter();
                break;

            case 'FalseFilter':
                $filter = new FalseFilter();
                break;

            case 'CorrelationFilter':
                $filter = new CorrelationFilter();

                if (array_key_exists('CorrelationId', $filterItemArray)) {
                    $filter->setCorrelationId(
                        (string) $filterItemArray['CorrelationId']
                    );
                }
                break;

            case 'SqlFilter':
                $filter = new SqlFilter();

                if (array_key_exists('SqlExpression', $filterItemArray)) {
                    $filter->setSqlExpression(
                        (string) $filterItemArray['SqlExpression']
                    );
                }
                if (array_key_exists('CompatibilityLevel', $filterItemArray)) {
                    $filter->setCompatibilityLevel(
                        (int) $filterItemArray['CompatibilityLevel']
                    );
                }

                break;

            default:
                $filter = new Filter();
            }

            $ruleDescription->setFilter($filter);
        }

        if (array_key_exists('Action', $ruleDescriptionArray)) {
            $actionItem = $ruleDescriptionArray['Action'];
            $actionAttributes = $actionItem->attributes('i', true);
            $actionType = (string) $actionAttributes['type'];
            $action = null;

            switch ($actionType) {
            case 'EmptyRuleAction':
                $action = new EmptyRuleAction();
                break;

            case 'SqlRuleAction':
                $action = new SqlRuleAction();

                if (array_key_exists('SqlExpression', $actionItem)) {
                    $action->setSqlExpression((string) $actionItem['SqlExpression']);
                }
                break;

            default:
                $action = new Action();
            }

            $ruleDescription->setAction($action);
        }

        if (array_key_exists('Name', $ruleDescriptionArray)) {
            $ruleDescription->setName((string) $ruleDescriptionArray['Name']);
        }

        return $ruleDescription;
    }
public static function create($ruleDescriptionXml)
    {
        $ruleDescription = new self();
        $root = simplexml_load_string(
            $ruleDescriptionXml
        );
        $ruleDescriptionArray = (array) $root;
        if (array_key_exists('Filter', $ruleDescriptionArray)) {
            $filterItem = $ruleDescriptionArray['Filter'];
            $filterAttributes = $filterItem->attributes('i', true);
            $filterItemArray = (array) $filterItem;
            $filterType = (string) $filterAttributes['type'];
            $filter = null;
            switch ($filterType) {
            case 'TrueFilter':
                $filter = new TrueFilter();
                break;

            case 'FalseFilter':
                $filter = new FalseFilter();
                break;

            case 'CorrelationFilter':
                $filter = new CorrelationFilter();

                if (array_key_exists('CorrelationId', $filterItemArray)) {
                    $filter->setCorrelationId(
                        (string) $filterItemArray['CorrelationId']
                    );
                }
                break;

            case 'SqlFilter':
                $filter = new SqlFilter();

                if (array_key_exists('SqlExpression', $filterItemArray)) {
                    $filter->setSqlExpression(
                        (string) $filterItemArray['SqlExpression']
                    );
                }
                if (array_key_exists('CompatibilityLevel', $filterItemArray)) {
                    $filter->setCompatibilityLevel(
                        (int) $filterItemArray['CompatibilityLevel']
                    );
                }

                break;

            default:
                $filter = new Filter();
            }

            $ruleDescription->setFilter($filter);
        }

        if (array_key_exists('Action', $ruleDescriptionArray)) {
            $actionItem = $ruleDescriptionArray['Action'];
            $actionAttributes = $actionItem->attributes('i', true);
            $actionType = (string) $actionAttributes['type'];
            $action = null;

            switch ($actionType) {
            case 'EmptyRuleAction':
                $action = new EmptyRuleAction();
                break;

            case 'SqlRuleAction':
                $action = new SqlRuleAction();

                if (array_key_exists('SqlExpression', $actionItem)) {
                    $action->setSqlExpression((string) $actionItem['SqlExpression']);
                }
                break;

            default:
                $action = new Action();
            }

            $ruleDescription->setAction($action);
        }

        if (array_key_exists('Name', $ruleDescriptionArray)) {
            $ruleDescription->setName((string) $ruleDescriptionArray['Name']);
        }

        return $ruleDescription;
    }
public static function create ( $ ruleDescriptionXml ) { $ ruleDescription = new self ( ) ; $ root = simplexml_load_string ( $ ruleDescriptionXml ) ; $ ruleDescriptionArray = ( array ) $ root ; if ( array_key_exists ( 'Filter' , $ ruleDescriptionArray ) ) { $ filterItem = $ ruleDescriptionArray [ 'Filter' ] ; $ filterAttributes = $ filterItem -> attributes ( 'i' , true ) ; $ filterItemArray = ( array ) $ filterItem ; $ filterType = ( string ) $ filterAttributes [ 'type' ] ; $ filter = null ; switch ( $ filterType ) { case 'TrueFilter' : $ filter = new TrueFilter ( ) ; break ; case 'FalseFilter' : $ filter = new FalseFilter ( ) ; break ; case 'CorrelationFilter' : $ filter = new CorrelationFilter ( ) ; if ( array_key_exists ( 'CorrelationId' , $ filterItemArray ) ) { $ filter -> setCorrelationId ( ( string ) $ filterItemArray [ 'CorrelationId' ] ) ; } break ; case 'SqlFilter' : $ filter = new SqlFilter ( ) ; if ( array_key_exists ( 'SqlExpression' , $ filterItemArray ) ) { $ filter -> setSqlExpression ( ( string ) $ filterItemArray [ 'SqlExpression' ] ) ; } if ( array_key_exists ( 'CompatibilityLevel' , $ filterItemArray ) ) { $ filter -> setCompatibilityLevel ( ( int ) $ filterItemArray [ 'CompatibilityLevel' ] ) ; } break ; default : $ filter = new Filter ( ) ; } $ ruleDescription -> setFilter ( $ filter ) ; } if ( array_key_exists ( 'Action' , $ ruleDescriptionArray ) ) { $ actionItem = $ ruleDescriptionArray [ 'Action' ] ; $ actionAttributes = $ actionItem -> attributes ( 'i' , true ) ; $ actionType = ( string ) $ actionAttributes [ 'type' ] ; $ action = null ; switch ( $ actionType ) { case 'EmptyRuleAction' : $ action = new EmptyRuleAction ( ) ; break ; case 'SqlRuleAction' : $ action = new SqlRuleAction ( ) ; if ( array_key_exists ( 'SqlExpression' , $ actionItem ) ) { $ action -> setSqlExpression ( ( string ) $ actionItem [ 'SqlExpression' ] ) ; } break ; default : $ action = new Action ( ) ; } $ ruleDescription -> setAction ( $ action ) ; } if ( array_key_exists ( 'Name' , $ ruleDescriptionArray ) ) { $ ruleDescription -> setName ( ( string ) $ ruleDescriptionArray [ 'Name' ] ) ; } return $ ruleDescription ; }
Creates a rule description instance with specified XML string.

@param string $ruleDescriptionXml A XML string representing the
rule description

@return RuleDescription
Creates a rule description instance with specified XML string .