1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?php
- namespace Predis\Configuration;
- use InvalidArgumentException;
- use Predis\Profile\ServerProfile;
- use Predis\Profile\ServerProfileInterface;
- class ProfileOption implements OptionInterface
- {
-
- protected function setProcessors(OptionsInterface $options, ServerProfileInterface $profile)
- {
- if (isset($options->prefix)) {
- $profile->setProcessor($options->prefix);
- }
- }
-
- public function filter(OptionsInterface $options, $value)
- {
- if (is_string($value)) {
- $value = ServerProfile::get($value);
- $this->setProcessors($options, $value);
- } else if (!$value instanceof ServerProfileInterface) {
- throw new InvalidArgumentException('Invalid value for the profile option');
- }
- return $value;
- }
-
- public function getDefault(OptionsInterface $options)
- {
- $profile = ServerProfile::getDefault();
- $this->setProcessors($options, $profile);
- return $profile;
- }
- }
|