Skip to content

Instantly share code, notes, and snippets.

View mcsee's full-sized avatar
🏠
Working from home

mcsee mcsee

🏠
Working from home
View GitHub Profile
<?
$triangle =
new Polygon([new Point(1, 1), new Point(2, 2), new Point(3, 3)]);
$lastPoint = $triangle->getVertices()->last();
foreach ($triangle->getVertices() as $vertex) {
$canvas->drawLine($vertex, $lastPoint);
$lastPoint = $vertex;
}
<?
$triangle = new
Polygon([(new Point(1,1), new Point(2,2), new Point(3,3))]);
array_shift($triangle->getVertices());
<?
function iterator(): Iterator {
return new ArrayIterator($this->vertices);
}
<?
function verticesDo($function) {
foreach ($this->vertices as $vertex) {
$$function($vertex);
}
}
<?
final class TwitterAccount {
private $followers;
private function __construct() {
$this->followers = [];
}
}
<?
$mcsee1 = new TwitterAccount('mcsee1');
$pontifex = new TwitterAccount('pontifex');
$mcsee1->getFollowers()[] = $pontifex;
<?
$mcsee1 = new TwitterAccount('mcsee1');
$pontifex = new TwitterAccount('pontifex');
$mcsee1->addFollower($pontifex);
<?
StrategySupervisedHelper::getInstance()->optimize($processId);
<?
StrategySupervisedHelper::getInstance()->optimize($processId);
<?
class StrategySupervisedHelper extends Singleton {
// ...
}