for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace FipeApi\Factories;
use FipeApi\Api\ConsultaCaminhaoApi;
use FipeApi\Api\ConsultaCarroApi;
use FipeApi\Api\ConsultaMotoApi;
use FipeApi\Constants\Tipo;
/**
* Class ConsultaApiFactory
*
* @package FipeApi
*/
class ConsultaApiFactory
{
* @param $tipo
* @return ConsultaMotoApi
* @throws \Exception
public static function getInstance($tipo)
switch($tipo)
case Tipo::MOTOS: return new ConsultaMotoApi();
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 Tipo::CAMINHOES: return new ConsultaCaminhaoApi();
case Tipo::CARROS: return new ConsultaCarroApi();
throw new \Exception("Tipo {$tipo} não definido");
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.