PageRenderTime 51ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/library/Zend/Tag/Cloud/Decorator/Cloud.php

http://github.com/zendframework/zf2
PHP | 86 lines | 32 code | 8 blank | 46 comment | 4 complexity | b62cdd3a961d73b68c0f94d45d05e6ef MD5 | raw file
Possible License(s): BSD-3-Clause
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Tag
  17. * @subpackage Cloud
  18. * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. */
  21. /**
  22. * @namespace
  23. */
  24. namespace Zend\Tag\Cloud\Decorator;
  25. use Zend\Tag\Cloud\Decorator;
  26. /**
  27. * Abstract class for cloud decorators
  28. *
  29. * @category Zend
  30. * @package Zend_Tag
  31. * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  32. * @license http://framework.zend.com/license/new-bsd New BSD License
  33. */
  34. abstract class Cloud implements Decorator
  35. {
  36. /**
  37. * Option keys to skip when calling setOptions()
  38. *
  39. * @var array
  40. */
  41. protected $_skipOptions = array(
  42. 'options',
  43. 'config',
  44. );
  45. /**
  46. * Create a new cloud decorator with options
  47. *
  48. * @param mixed $options
  49. */
  50. public function __construct($options = null)
  51. {
  52. if ($options instanceof \Zend\Config\Config) {
  53. $options = $options->toArray();
  54. }
  55. if (is_array($options)) {
  56. $this->setOptions($options);
  57. }
  58. }
  59. /**
  60. * Set options from array
  61. *
  62. * @param array $options Configuration for the decorator
  63. * @return \Zend\Tag\Cloud
  64. */
  65. public function setOptions(array $options)
  66. {
  67. foreach ($options as $key => $value) {
  68. if (in_array(strtolower($key), $this->_skipOptions)) {
  69. continue;
  70. }
  71. $method = 'set' . $key;
  72. if (method_exists($this, $method)) {
  73. $this->$method($value);
  74. }
  75. }
  76. return $this;
  77. }
  78. }