for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace GeoPhone\EndpointFactory;
use GeoPhone\Endpoints\v1\PhoneNumbers;
use GeoPhone\Models\GeoPhone;
use LunixREST\Endpoint\Endpoint;
use LunixREST\Endpoint\Exceptions\UnknownEndpointException;
class EndpointFactory implements \LunixREST\Endpoint\EndpointFactory {
protected $geoPhone;
public function __construct(GeoPhone $geoPhone) {
$this->geoPhone = $geoPhone;
}
/**
* @param string $name
* @param string $version
* @return Endpoint
* @throws UnknownEndpointException
*/
public function getEndpoint(string $name, string $version): Endpoint {
switch($version) {
case "1":
switch (strtolower($name)) {
case "phonenumbers":
return new PhoneNumbers($this->geoPhone);
break;
break
The break statement is not necessary if it is preceded for example by a return statement:
switch ($x) { case 1: return 'foo'; break; // This break is not necessary and can be left off. }
If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.
default:
throw new UnknownEndpointException("Endpoint: $name not supported");
throw new UnknownEndpointException("Version: $version not support");
* @return string[]
public function getSupportedEndpoints(string $version): array {
return ["phonenumbers"];
The break statement is not necessary if it is preceded for example by a return statement:
If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.