for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Samerior\MobileMoney\Equity\Library;
class Validator
{
/**
* Required keys.
*
* @var array
*/
const RULES = [
'VA_PAYBILL',
'VA_PASSWORD',
'VA_TIMESTAMP',
'VA_TRANS_ID',
'VA_REF_ID',
'VA_AMOUNT',
'VA_NUMBER',
'VA_CALL_URL',
'VA_CALL_METHOD'
];
* Check if key exists else throw exception.
* @param array $data
* @return bool
* @throws InvalidRequestException
public static function validate($data = [])
$data
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.
return true;
foreach (static::RULES as $value) {
foreach (static::RULES a...RRORS[$value]); } }
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
if (!array_key_exists($value, $data)) {
throw new InvalidRequestException(InvalidRequestException::ERRORS[$value]);
}
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.