count()) $helpers->push(''); $helpers = $helpers ->merge([$class::id()=>$class]); } return $helpers; } /** * Return the object that will process a password * * @param string $id * @return Base|null */ public static function hash(string $id): ?Attribute\Password\Base { return ($helpers=static::helpers())->has($id) ? new ($helpers->get($id)) : NULL; } /** * Given an LDAP password syntax {xxx}yyyyyy, this function will return xxx * * @param string $password * @return string */ public static function hash_id(string $password): string { $m = []; preg_match('/^{([A-Z]+)}(.*)$/',$password,$m); return Arr::get($m,1,'Clear'); } public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE): View { return view('components.attribute.password') ->with('o',$this) ->with('edit',$edit) ->with('old',$old) ->with('new',$new) ->with('helpers',static::helpers()->map(fn($item,$key)=>['id'=>$key,'value'=>$key])); } public function render_item_old(int $key): ?string { return Arr::get($this->oldValues,$key) ? str_repeat('x',8) : NULL; } public function render_item_new(int $key): ?string { return Arr::get($this->values,$key) ? str_repeat('x',8) : NULL; } }