Skip to content
This repository has been archived by the owner on Nov 8, 2020. It is now read-only.

Commit

Permalink
Class to interface typehint
Browse files Browse the repository at this point in the history
  • Loading branch information
klapuch committed Mar 25, 2017
1 parent 8e531f8 commit 2035420
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions Core/DefaultInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,24 @@
*/
final class DefaultInput implements Control {
private $attributes;
private $backup;
private $storage;
private $rule;

public function __construct(
array $attributes,
Backup $backup,
Storage $storage,
Validation\Rule $rule
) {
$this->attributes = $attributes;
$this->backup = $backup;
$this->storage = $storage;
$this->rule = $rule;
}

public function validate(): void {
$name = $this->attributes['name'] ?? null;
$this->backup->archive($name);
if (isset($this->backup[$name]))
$this->rule->apply($this->backup[$name]);
$this->storage->archive($name);
if (isset($this->storage[$name]))
$this->rule->apply($this->storage[$name]);
}

public function render(): string {
Expand All @@ -40,9 +40,9 @@ public function render(): string {

private function attribute(): Markup\Attribute {
$name = $this->attributes['name'] ?? null;
if (isset($this->backup[$name]))
$this->attributes['value'] = $this->backup[$name];
unset($this->backup[$name]);
if (isset($this->storage[$name]))
$this->attributes['value'] = $this->storage[$name];
unset($this->storage[$name]);
return new Markup\ArrayAttribute($this->attributes);
}
}

0 comments on commit 2035420

Please sign in to comment.