for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Recca0120\Twzipcode;
class Point
{
/**
* $x.
*
* @var int
*/
public $x = 0;
* $y.
public $y = 0;
* __construct.
* @param int $x
* @param int $y
public function __construct($x = 0, $y = 0)
$this->x = $x;
$this->y = $y;
}
* empty.
* @return bool
public function isEmpty()
return $this->x === 0 && $this->y === 0;
* compare.
* @param Point $point
* @param string $operator
public function compare(Point $point, $operator = '=')
$sum = $this->x * 10 + $this->y;
$sum2 = $point->x * 10 + $point->y;
switch ($operator) {
case '>': return $sum > $sum2;
According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.
switch ($expr) { case "A": doSomething(); //right break; case "B": doSomethingElse(); //wrong break;
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.
As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.
break
switch ($expr) { case "A": doSomething(); break; //wrong case "B": doSomething(); break; //right case "C:": doSomething(); return true; //right }
case '>=': return $sum >= $sum2;
case '<': return $sum < $sum2;
case '<=': return $sum <= $sum2;
return $sum === $sum2;
According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.