Skip to content

Instantly share code, notes, and snippets.

@VictorFursa
Created July 16, 2017 17:27
Show Gist options
  • Save VictorFursa/b1f8acfcc24f41ed9cc73ac247ba0d43 to your computer and use it in GitHub Desktop.
Save VictorFursa/b1f8acfcc24f41ed9cc73ac247ba0d43 to your computer and use it in GitHub Desktop.
WebbyLab
<?php
abstract class Animal
{
/**
* @var Animal|string $name
*/
protected $name;
/**
* Animal constructor.
* @param string $name
*/
public function __construct(string $name)
{
return $this->name = $name;
}
abstract protected function getName();
}
<?php
class Cat extends Animal
{
/**
* Cat constructor.
* @param string $name
*/
public function __construct(string $name)
{
return parent::__construct($name);
}
/**
* @return Animal|string
*/
public function getName()
{
return $this->name;
}
/**
* @return string
*/
public function meow()
{
return "Cat $this->name is saying meow";
}
}
$cat = new Cat('garfield');
echo $cat->getName();
echo $cat->meow();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment