Skip to content

Instantly share code, notes, and snippets.

@tacoberu
Created October 7, 2015 13:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tacoberu/6de6568728081f6a360f to your computer and use it in GitHub Desktop.
Save tacoberu/6de6568728081f6a360f to your computer and use it in GitHub Desktop.
Jak přidat do existující třídy novou funkcionalitu. Anemicky.
<?php
class Int
{
function __construct($value){}
function getValue(){}
}
class IntPlusOp
{
function invoke(Int $m){}
}
class IntMinusOp
{
function invoke(Int $m){}
}
class IntIncOp
{
function invoke(Int $m){}
}
$a = new Int(1);
$b = new Int(2);
$c = new Int(3);
(new IntIncOp())->invoke($a);
(new IntIncOp())->invoke($b);
(new IntIncOp())->invoke($c);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment