Skip to content

Commit

Permalink
Added getters and setters to Element.php
Browse files Browse the repository at this point in the history
  • Loading branch information
phrenotype committed Sep 11, 2023
1 parent 9cf83d3 commit e6533e4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
15 changes: 9 additions & 6 deletions Safari/Element.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ class Element

private $__html__;


public $type = 'text';
public $value = '';

private $attributes = [];

/**
* Create a form element.
Expand All @@ -33,16 +30,22 @@ public function __construct(string $name, array $request = [], array $attributes
$this->$k = $v;
}
}
$this->attributes['name'] = $name;
}

public function __set($name, $value)
{
$this->attributes[$name] = $value;
}

public function __get($name)
{
return null;
return $this->attributes[$name] ?? null;
}

public function stringify(): string
{
$array = get_object_vars($this);
$array = $this->attributes;
if (!empty($array)) {
$keys = array_keys($array);
$values = array_values($array);
Expand Down
2 changes: 2 additions & 0 deletions Tests/FieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
class FieldTest extends TestCase
{

protected $field;

protected function setUp(): void
{
//Field::setRequest([]);
Expand Down

0 comments on commit e6533e4

Please sign in to comment.