PageRenderTime 56ms CodeModel.GetById 30ms RepoModel.GetById 0ms app.codeStats 0ms

/public/plugin/ckfinder/core/connector/php/vendor/microsoft/windowsazure/WindowsAzure/ServiceBus/Models/RuleDescription.php

https://gitlab.com/vietdhtn/myweb
PHP | 240 lines | 111 code | 33 blank | 96 comment | 9 complexity | 5a4884fb2ee7ec88f13b09d43bd20022 MD5 | raw file
  1. <?php
  2. /**
  3. * LICENSE: Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. * http://www.apache.org/licenses/LICENSE-2.0
  7. *
  8. * Unless required by applicable law or agreed to in writing, software
  9. * distributed under the License is distributed on an "AS IS" BASIS,
  10. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. * See the License for the specific language governing permissions and
  12. * limitations under the License.
  13. *
  14. * PHP version 5
  15. *
  16. * @category Microsoft
  17. * @package WindowsAzure\ServiceBus\Models
  18. * @author Azure PHP SDK <azurephpsdk@microsoft.com>
  19. * @copyright 2012 Microsoft Corporation
  20. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
  21. * @link https://github.com/WindowsAzure/azure-sdk-for-php
  22. */
  23. namespace WindowsAzure\ServiceBus\Models;
  24. use WindowsAzure\Common\Internal\Resources;
  25. use WindowsAzure\Common\Internal\Utilities;
  26. use WindowsAzure\ServiceBus\Internal\Action;
  27. use WindowsAzure\ServiceBus\Internal\Filter;
  28. /**
  29. * The description of the rule.
  30. *
  31. * @category Microsoft
  32. * @package WindowsAzure\ServiceBus\Models
  33. * @author Azure PHP SDK <azurephpsdk@microsoft.com>
  34. * @copyright 2012 Microsoft Corporation
  35. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
  36. * @version Release: 0.4.0_2014-01
  37. * @link http://msdn.microsoft.com/en-us/library/windowsazure/hh780753
  38. */
  39. class RuleDescription
  40. {
  41. /**
  42. * The filter of the rule.
  43. *
  44. * @var Filter
  45. */
  46. private $_filter;
  47. /**
  48. * The action of the rule.
  49. *
  50. * @var Action
  51. */
  52. private $_action;
  53. /**
  54. * The name of the rule.
  55. *
  56. * @var string
  57. */
  58. private $_name;
  59. /**
  60. * Creates a rule description instance with default parameters.
  61. */
  62. public function __construct()
  63. {
  64. }
  65. // @codingStandardsIgnoreStart
  66. /**
  67. * Creates a rule description instance with specified XML string.
  68. *
  69. * @param string $ruleDescriptionXml A XML string representing the
  70. * rule description.
  71. *
  72. * @return none
  73. */
  74. public static function create($ruleDescriptionXml)
  75. {
  76. $ruleDescription = new RuleDescription();
  77. $root = simplexml_load_string(
  78. $ruleDescriptionXml
  79. );
  80. $nameSpaces = $root->getNameSpaces();
  81. $ruleDescriptionArray = (array)$root;
  82. if (array_key_exists('Filter', $ruleDescriptionArray)) {
  83. $filterItem = $ruleDescriptionArray['Filter'];
  84. $filterAttributes = $filterItem->attributes('i', true);
  85. $filterItemArray = (array)$filterItem;
  86. $filterType = (string)$filterAttributes['type'];
  87. $filter = null;
  88. switch ($filterType) {
  89. case 'TrueFilter' :
  90. $filter = new TrueFilter();
  91. break;
  92. case 'FalseFilter' :
  93. $filter = new FalseFilter();
  94. break;
  95. case 'CorrelationFilter' :
  96. $filter = new CorrelationFilter();
  97. if (array_key_exists('CorrelationId', $filterItemArray)) {
  98. $filter->setCorrelationId(
  99. (string)$filterItemArray['CorrelationId']
  100. );
  101. }
  102. break;
  103. case 'SqlFilter' :
  104. $filter = new SqlFilter();
  105. if (array_key_exists('SqlExpression', $filterItemArray)) {
  106. $filter->setSqlExpression(
  107. (string)$filterItemArray['SqlExpression']
  108. );
  109. }
  110. if (array_key_exists('CompatibilityLevel', $filterItemArray)) {
  111. $filter->setCompatibilityLevel(
  112. (integer)$filterItemArray['CompatibilityLevel']
  113. );
  114. }
  115. break;
  116. default :
  117. $filter = new Filter();
  118. }
  119. $ruleDescription->setFilter($filter);
  120. }
  121. if (array_key_exists('Action', $ruleDescriptionArray)) {
  122. $actionItem = $ruleDescriptionArray['Action'];
  123. $actionAttributes = $actionItem->attributes('i', true);
  124. $actionType = (string)$actionAttributes['type'];
  125. $action = null;
  126. switch ($actionType) {
  127. case 'EmptyRuleAction' :
  128. $action = new EmptyRuleAction();
  129. break;
  130. case 'SqlRuleAction' :
  131. $action = new SqlRuleAction();
  132. if (array_key_exists('SqlExpression', $actionItem)) {
  133. $action->setSqlExpression((string)$actionItem['SqlExpression']);
  134. }
  135. break;
  136. default :
  137. $action = new Action();
  138. }
  139. $ruleDescription->setAction($action);
  140. }
  141. if (array_key_exists('Name', $ruleDescriptionArray)) {
  142. $ruleDescription->setName((string)$ruleDescriptionArray['Name']);
  143. }
  144. return $ruleDescription;
  145. }
  146. // @codingStandardsIgnoreEnd
  147. /**
  148. * Gets the filter.
  149. *
  150. * @return Filter
  151. */
  152. public function getFilter()
  153. {
  154. return $this->_filter;
  155. }
  156. /**
  157. * Sets the filter of the rule description.
  158. *
  159. * @param Filter $filter The filter of the rule description.
  160. *
  161. * @return none
  162. */
  163. public function setFilter($filter)
  164. {
  165. $this->_filter = $filter;
  166. }
  167. /**
  168. * Gets the action.
  169. *
  170. * @return Action
  171. */
  172. public function getAction()
  173. {
  174. return $this->_action;
  175. }
  176. /**
  177. * Sets the action of the rule description.
  178. *
  179. * @param Action $action The action of the rule description.
  180. *
  181. * @return none
  182. */
  183. public function setAction($action)
  184. {
  185. $this->_action = $action;
  186. }
  187. /**
  188. * Gets the name of the rule description.
  189. *
  190. * @return string
  191. */
  192. public function getName()
  193. {
  194. return $this->_name;
  195. }
  196. /**
  197. * Sets the name of the rule description.
  198. *
  199. * @param string $name The name of the rule description.
  200. *
  201. * @return none
  202. */
  203. public function setName($name)
  204. {
  205. $this->_name = $name;
  206. }
  207. }