Created
September 29, 2013 23:21
-
-
Save nicolas-brousse/6757447 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Opsone\Util; | |
class Frame | |
{ | |
protected $point; | |
protected $size; | |
public function __construct(Point $point, Size $size) | |
{ | |
$this->point = $point; | |
$this->size = $size; | |
} | |
public function __toString() | |
{ | |
return __CLASS__ . '@' . spl_object_hash($this); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Opsone\Util; | |
class Line | |
{ | |
protected $a; | |
protected $b; | |
public function __construct(Point $a, Point $b) | |
{ | |
$this->a = $a; | |
$this->b = $b; | |
} | |
public function intersect(Line $line) | |
{ | |
} | |
public function middle() | |
{ | |
$x = ($this->a->x() + $this->b->x()) / 2; | |
$x = ($this->a->y() + $this->b->y()) / 2; | |
return new Point($x, $y); | |
} | |
public function __toString() | |
{ | |
return __CLASS__ . '@' . spl_object_hash($this); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Opsone\Util; | |
class Math | |
{ | |
public static function square($num) | |
{ | |
return pow($num, 2); | |
} | |
public static function cube($num) | |
{ | |
return pow($num, 3); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Opsone\Util; | |
class Point | |
{ | |
protected $x; | |
protected $y; | |
public function __construct($x=null, $y=null) | |
{ | |
$this->x = null; | |
$this->y = null; | |
} | |
public function x() | |
{ | |
return $this->x; | |
} | |
public function y() | |
{ | |
return $this->y; | |
} | |
public function distance(Point $b) | |
{ | |
return sqrt( Math::square($b->x() - $this->x()) + Math::square($b->y() - $this->y()) ); | |
} | |
public function __toString() | |
{ | |
return __CLASS__ . '@' . spl_object_hash($this); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Opsone\Util; | |
class Size | |
{ | |
protected $width; | |
protected $height; | |
public function __construct($width, $height) | |
{ | |
$this->width = $width; | |
$this->height = $height; | |
} | |
public function __toString() | |
{ | |
return __CLASS__ . '@' . spl_object_hash($this); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Opsone\Util; | |
class Volume extends Size | |
{ | |
protected $depth; | |
public function __construct($width, $height, $depth) | |
{ | |
$this->depth = $depth; | |
parent::__construct($width, $height); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment