Showing 64 of 84 total issues
Method convertFromUTF7
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function convertFromUTF7(string $value): string
{
if (preg_match('/\+A\w+-?/m', $value)) {
if (function_exists('mb_convert_encoding')) {
$value .= "\n" . mb_convert_encoding($value, 'UTF-8', 'UTF-7');
Method convertFromConcatenated
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function convertFromConcatenated(string $value): string
{
//normalize remaining backslashes
if ($value != preg_replace('/(\w)\\\/', "$1", $value)) {
$value .= preg_replace('/(\w)\\\/', "$1", $value);
Method nested
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function nested(string $key, array $rules): Rule
{
$resultRule = new Rule(null, "", "nested");
foreach ($rules as $rule) {
if (!($rule instanceof Rule)) {
Method uploadAsChunks
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function uploadAsChunks(string $filePath, array $payload = [], ?callable $callback = null, int $chuckSize = 1024000 * 20)
{
if (!is_readable($filePath)) {
throw new InvalidArgumentException("Specified filepath [$filePath] is not readable and thus cannot be prepared as a remote request file transfer.");
}
Method iteration
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function iteration(array $rules, string $mode = 'values'): Rule
{
$resultRule = new Rule(null, "", ($mode == 'values') ? "each" : "eachKey");
foreach ($rules as $rule) {
if (!($rule instanceof Rule)) {
Method initializeRoutesFromAttributes
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function initializeRoutesFromAttributes(RouteRepository $repository): void
{
$class = new ReflectionClass(static::class);
$baseRoute = self::initializeBaseRoute($class);
$result = self::initializeBaseAuthorizationRules($class);
Method getallheaders
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getallheaders(): array
{
$headers = [];
$copy_server = [
'CONTENT_TYPE' => 'Content-Type',
Function restrictArguments
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
private function restrictArguments(Controller $controller, RouteDefinition $route): void
{
$parameterNames = $route->getArgumentNames();
foreach ($controller->getRestrictedArguments() as $name => $rules) {
if (in_array($name, $parameterNames)) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function convertFromSQLHex
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
private function convertFromSQLHex(string $value): string
{
$matches = [];
if (preg_match_all('/(?:(?:\A|[^\d])0x[a-f\d]{3,}[a-f\d]*)+/im', $value, $matches)) {
foreach ($matches[0] as $match) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method buildResponse
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function buildResponse(): Response
{
ob_start(); ?>
BEGIN:VCALENDAR
VERSION:2.0
Method download
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function download(string $filePath, ?string $filename = null, bool $deleteAfter = false): Response
{
if (!File::exists($filePath)) {
throw new InvalidArgumentException("Specified file doesn't exists");
}
Consider simplifying this complex logical expression. Open
if (empty($uuid) || empty($chunk) || empty($totalChunks) || empty($totalFileSize)
|| !is_numeric($chunk) || !is_numeric($totalChunks) || !is_numeric($totalFileSize)) {
throw HttpUploadException::invalidChunk();
}
Function detectIntrusion
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function detectIntrusion(stdClass $rule, $parameter, $data, IntrusionReport $report)
{
if (is_array($data)) {
foreach ($data as $key => $value) {
$this->detectIntrusion($rule, $parameter . '.' . $key, $value, $report);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function zip
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function zip(string $zipPath, ?string $password = null, int $encryptionMethod = ZipArchive::EM_AES_256): ZipArchive
{
$zip = new ZipArchive();
if ($zip->open($zipPath, ZipArchive::CREATE) === true) {
foreach ($this->getFiles() as $file) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function copyRecursively
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function copyRecursively(string $source, string $destination)
{
$dir = opendir($source);
@mkdir($destination);
while (false !== ($file = readdir($dir))) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function run
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function run(): void
{
$failedRules = [];
$successRules = [];
$isStrict = $this->request->getRouteDefinition()->isStrictRuleInterpretation();
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Consider simplifying this complex logical expression. Open
if ($this->isGetSecured() && $method == "GET") {
return true;
} elseif ($this->isPostSecured() && $method == "POST") {
return true;
} elseif ($this->isPutSecured() && $method == "PUT") {
Function buildHeaderLine
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function buildHeaderLine(string $name, array $sources): string
{
$header = '';
if (!empty($sources)) {
$value = "";
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function injectForms
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function injectForms(string $html): string
{
preg_match_all("/<form(.*?)>(.*?)<\\/form>/is", $html, $matches, PREG_SET_ORDER);
if (is_array($matches)) {
foreach ($matches as $match) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function buildCurlFile
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function buildCurlFile(?string $uploadFilename = null): CURLFile
{
if (is_null($uploadFilename)) {
$uploadFilename = $this->getBasename();
} else {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"