Skip to content

Instantly share code, notes, and snippets.

@ircmaxell
Created January 26, 2012 13:52
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 ircmaxell/1682854 to your computer and use it in GitHub Desktop.
Save ircmaxell/1682854 to your computer and use it in GitHub Desktop.
Decorator Implementation
<?php
class Ruler {
// Returns in meters
public function measure(Point $a, Point $b) {
}
}
class SAEDecorator {
protected $ruler;
public function __construct(Ruler $ruler) {
$this->ruler = $ruler;
}
// Returns in feet
public function measure(Point $a, Point $b) {
return 3.2808399 * $this->ruler->measure($a, $b);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment