Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save clayhinson/854888 to your computer and use it in GitHub Desktop.
Save clayhinson/854888 to your computer and use it in GitHub Desktop.
<?php
class Coordinate
{
protected $x;
protected $y;
public function __construct($x = null, $y = null)
{
(empty($x)) ?: $this->setX($x);
(empty($y)) ?: $this->setY($y);
}
/* What we're trying to replace
public function __construct($x = null, $y = null)
{
if ($x) {
$this->setX($x);
}
if ($y) {
$this->setY($y);
}
}
*/
public function setX($x)
{
$this->x = $x;
}
public function setY($y)
{
$this->y = $y;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment