fix calendar css, take 2. (#213)
[openemr.git] / interface / modules / zend_modules / library / Zend / Captcha / AbstractAdapter.php
blob70642e650ae812d66c9eb62815ab1c4ac6eee0ba
1 <?php
2 /**
3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
8 */
10 namespace Zend\Captcha;
12 use Traversable;
13 use Zend\Validator\AbstractValidator;
15 /**
16 * Base class for Captcha adapters
18 * Provides some utility functionality to build on
20 abstract class AbstractAdapter extends AbstractValidator implements AdapterInterface
22 /**
23 * Captcha name
25 * Useful to generate/check form fields
27 * @var string
29 protected $name;
31 /**
32 * Captcha options
34 * @var array
36 protected $options = array();
38 /**
39 * Options to skip when processing options
40 * @var array
42 protected $skipOptions = array(
43 'options',
44 'config',
47 /**
48 * Get name
50 * @return string
52 public function getName()
54 return $this->name;
57 /**
58 * Set name
60 * @param string $name
61 * @return AbstractAdapter
63 public function setName($name)
65 $this->name = $name;
66 return $this;
69 /**
70 * Set single option for the object
72 * @param string $key
73 * @param string $value
74 * @return AbstractAdapter
76 public function setOption($key, $value)
78 if (in_array(strtolower($key), $this->skipOptions)) {
79 return $this;
82 $method = 'set' . ucfirst($key);
83 if (method_exists($this, $method)) {
84 // Setter exists; use it
85 $this->$method($value);
86 $this->options[$key] = $value;
87 } elseif (property_exists($this, $key)) {
88 // Assume it's metadata
89 $this->$key = $value;
90 $this->options[$key] = $value;
92 return $this;
95 /**
96 * Set object state from options array
98 * @param array|Traversable $options
99 * @throws Exception\InvalidArgumentException
100 * @return AbstractAdapter
102 public function setOptions($options = array())
104 if (!is_array($options) && !$options instanceof Traversable) {
105 throw new Exception\InvalidArgumentException(__METHOD__ . ' expects an array or Traversable');
108 foreach ($options as $key => $value) {
109 $this->setOption($key, $value);
111 return $this;
115 * Retrieve options representing object state
117 * @return array
119 public function getOptions()
121 return $this->options;
125 * Get helper name used to render captcha
127 * By default, return empty string, indicating no helper needed.
129 * @return string
131 public function getHelperName()
133 return '';