for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* \Wicked\Timely\PushServices\PushServiceFactory
*
* NOTICE OF LICENSE
* This source file is subject to the Open Software License (OSL 3.0)
* that is available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* PHP version 5
* @author wick-ed
* @copyright 2019 Bernhard Wick
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @link https://github.com/wick-ed/timely
*/
namespace Wicked\Timely\PushServices;
use Symfony\Component\Console\Output\OutputInterface;
use Wicked\Timely\DotEnvConfiguration;
use Wicked\Timely\PushServices\Authentication\MacOsPasswordRetrievalStrategy;
* Push Service factory
class PushServiceFactory
{
* Get a push service as configured
* @return PushServiceInterface
* @throws \JiraRestApi\JiraException
public static function getService(OutputInterface $output)
$configuration = new DotEnvConfiguration();
$pushService = $configuration->getPushService();
switch ($pushService) {
case 'jira':
$passwordRetrievalStrategy = new MacOsPasswordRetrievalStrategy($output, $configuration);
$pushService = new Jira($passwordRetrievalStrategy);
break;
default:
throw new \Exception(sprintf('Cannot create push service instance for "%s" configuration value', $pushService));
This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.
Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.
return
die
exit
function fx() { try { doSomething(); return true; } catch (\Exception $e) { return false; } return false; }
In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.
return false
}
return $pushService;
This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.
Unreachable code is most often the result of
return
,die
orexit
statements that have been added for debug purposes.In the above example, the last
return false
will never be executed, because a return statement has already been met in every possible execution path.