Created
July 9, 2019 12:25
-
-
Save str/79e7501bd349fb5e56f4d34189e78279 to your computer and use it in GitHub Desktop.
demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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