Skip to content

Instantly share code, notes, and snippets.

@str
Created July 9, 2019 12:25
Show Gist options
  • Save str/79e7501bd349fb5e56f4d34189e78279 to your computer and use it in GitHub Desktop.
Save str/79e7501bd349fb5e56f4d34189e78279 to your computer and use it in GitHub Desktop.
demo
<?php
abstract class SomeAbstractClass
{
protected $name;
public function getName()
{
return $this->name;
}
}
interface SomeInterface
{
public function getName();
}
class Demo extends SomeAbstractClass implements SomeInterface
{
/**
* Sets a value to a key of the class.
*
* @property string $key The key to be set.
* @property string $value The value to set in the key.
* @return self
*/
public function setValue($key, $value)
{
$this->$key = $value;
return $this;
}
}
$x = new Demo();
$x->setValue('name', 'Stuardo Rodríguez');
$x->setValue('experience', 'high');
var_dump($x, $x->getName());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment