Skip to content

Instantly share code, notes, and snippets.

@blizzarddreams
Last active December 17, 2015 22:19
Show Gist options
  • Select an option

  • Save blizzarddreams/bf9675adadca77b56610 to your computer and use it in GitHub Desktop.

Select an option

Save blizzarddreams/bf9675adadca77b56610 to your computer and use it in GitHub Desktop.
<?php
namespace Dog\App;
use Dog\Dog;
$beethoven = new Dog("Beethoven");
$beethoven->bark();
<?php
namespace Dog\Dog;
class Dog
{
private $name;
private static $dogCount = 0;
function __construct($name = null)
{
$this->name = $name ?? "A Dog";
self::$dogCount += 1;
}
function __toString()
{
return "<Dog:$this->name>";
}
function bark()
{
echo "$this->name goes bark!\n";
}
static function dogCount()
{
return self::$dogCount;
}
static function allDogsBark(...$dogs)
{
foreach($dogs as $dog)
{
$dog->bark();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment