Skip to content

Commit

Permalink
Merge pull request #145 from djlambert/develop
Browse files Browse the repository at this point in the history
Additional Point test and minor tweaks
  • Loading branch information
sadortun committed Apr 7, 2016
2 parents dad1285 + a23d299 commit 40bc131
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
16 changes: 7 additions & 9 deletions lib/CrEOF/Spatial/PHP/Types/AbstractPoint.php
Expand Up @@ -64,7 +64,7 @@ public function __construct()
*/
public function setX($x)
{
if (!is_numeric($x)) {
if (! is_numeric($x)) {
$parser = new Parser($x);

try {
Expand Down Expand Up @@ -97,7 +97,7 @@ public function getX()
*/
public function setY($y)
{
if (!is_numeric($y)) {
if (! is_numeric($y)) {
$parser = new Parser($y);

try {
Expand Down Expand Up @@ -185,12 +185,12 @@ protected function validateArguments(array $argv = null)
{
$argc = count($argv);

if (1 == $argc && is_array($argv[0])) {
if (1 === $argc && is_array($argv[0])) {
return $argv[0];
}

if (2 == $argc) {
if (is_array($argv[0]) && (is_numeric($argv[1]) || is_null($argv[1]) || is_string($argv[1]))) {
if (2 === $argc) {
if (is_array($argv[0]) && (is_numeric($argv[1]) || null === $argv[1] || is_string($argv[1]))) {
$argv[0][] = $argv[1];

return $argv[0];
Expand All @@ -201,10 +201,8 @@ protected function validateArguments(array $argv = null)
}
}

if (3 == $argc) {
if ((is_numeric($argv[0]) || is_string($argv[0])) && (is_numeric($argv[1]) || is_string($argv[1])) && (is_numeric($argv[2]) || is_null($argv[2]) || is_string($argv[2]))) {
return $argv;
}
if (3 === $argc && ((is_numeric($argv[0]) || is_string($argv[0])) && (is_numeric($argv[1]) || is_string($argv[1])) && (is_numeric($argv[2]) || null === $argv[2] || is_string($argv[2])))) {
return $argv;
}

array_walk($argv, function (&$value) {
Expand Down
7 changes: 6 additions & 1 deletion tests/CrEOF/Spatial/Tests/PHP/Types/Geometry/PointTest.php
Expand Up @@ -35,12 +35,17 @@
*/
class PointTest extends \PHPUnit_Framework_TestCase
{
public function testGoodNumericPoint()
public function testGoodNumericPoints()
{
$point1 = new Point(-73.7562317, 42.6525793);

$this->assertEquals(42.6525793, $point1->getLatitude());
$this->assertEquals(-73.7562317, $point1->getLongitude());

$point2 = new Point(0.00001, 0.00003);

$this->assertEquals(0.00003, $point2->getLatitude());
$this->assertEquals(0.00001, $point2->getLongitude());
}

public function testGoodStringPoints()
Expand Down

0 comments on commit 40bc131

Please sign in to comment.