Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?PHP
- FINAL CLASS eUserInfoComponents EXTENDS \ILLI\Core\Enum IMPLEMENTS \ILLI\Core\iProviderBitwise
- {
- /**
- * @const int ILLI\System\UserInfo::$username
- */
- const USERNAME = 1;
- /**
- * @const int ILLI\System\UserInfo::$password
- */
- const PASSWORD = 2;
- /**
- * @const int ILLI\System\UserInfo::$username
- * | ILLI\System\UserInfo::$password
- */
- const PASSPORT = 4;
- const MY_TEST = 3;
- }
- NAMESPACE ILLI\System;
- CLASS UserInfo EXTENDS \ILLI\Core\Table IMPLEMENTS \ILLI\Core\iProviderArrayList
- {
- const USERNAME_PASSWORD_DELIMETER = ':';
- const PASSPORT_DELIMETER = '@';
- private $__UserInfoComponents = NULL;
- public function __construct(array $config = array())
- {
- $this->__UserInfoComponents = eUserInfoComponents::instanceGet();
- $default = [
- 'username' => '',
- 'password' => '',
- 'passport' => ''
- ];
- $config += $default;
- parent::__construct($config);
- $self = $this;
- $this
- ->filterRegisterEventClosure(\ILLI\Core\eFilter::ARGUMENTS, 'ILLI\Core\Table::__set', function($data) use ($self)
- {
- $index = $data['index'];
- $value = $data['value'];
- switch($index):
- case 'username':
- $this->passport = $value.static::USERNAME_PASSWORD_DELIMETER.$this->password;
- break;
- case 'password':
- $this->passport = $this->username.static::USERNAME_PASSWORD_DELIMETER.$value;
- break;
- case 'passport':
- $value = $value.static::PASSPORT_DELIMETER;
- break;
- endswitch;
- return ['index' => $index, 'value' => $value];
- });
- }
- public function __call($name, array $args = array())
- {
- if(TRUE === $this->adapterTriggerExists(__METHOD__))
- return $this->adapterCallAlias(__METHOD__, $args);
- $filtered = $this->filterApply(\ILLI\Core\eFilter::METHOD, __METHOD__, ['method' => $name, 'args' => $args]);
- $name = $filtered['method'];
- $args = $filtered['args'];
- $c = $this->__UserInfoComponents;
- $value = '';
- foreach($c::$name()->enumGetVariablesArray() as $index)
- {
- $result = $this->$index;
- $value .= $result;
- }
- $this->observerNotify(__METHOD__, $name, $value, $args);
- $value = $this->filterApply(\ILLI\Core\eFilter::RESULT, __METHOD__, $value);
- return $value;
- }
- }
- $user = new UserInfo;
- $user->username = 'baz';
- $user->password = '$s:@!ioe';
- print $user->passport(); // baz:$s:@!ioe@
- print $user->myTest(); // baz$s:@!ioe
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement