t1gor/Robots.txt-Parser-Class

View on GitHub
source/Stream/Filters/SkipCommentedLinesFilter.php

Summary

Maintainability
B
5 hrs
Test Coverage

Showing 23 of 23 total issues

Avoid unused parameters such as '$closing'.
Open

public function filter($in, $out, &$consumed, $closing) {

Define a constant instead of duplicating this literal "logger" 3 times.
Open

&& isset($this->params['logger'])

Similar blocks of code found in 2 locations. Consider refactoring.
Open

<?php declare(strict_types=1);
 
namespace t1gor\RobotsTxtParser\Stream\Filters;
 
use Psr\Log\LoggerInterface;
Severity: Major
Found in source/Stream/Filters/SkipCommentedLinesFilter.php and 1 other location - About 5 hrs to fix
source/Stream/Filters/SkipEndOfCommentedLineFilter.php on lines 1..31

Avoid variables with short names like $in. Configured minimum length is 3.
Open

public function filter($in, $out, &$consumed, $closing) {

Opening brace of a class must be on the line after the definition
Open

class SkipCommentedLinesFilter extends \php_user_filter implements CustomFilterInterface {

Spaces must be used to indent lines; tabs are not allowed
Open

while ($bucket = stream_bucket_make_writeable($in)) {

Spaces must be used to indent lines; tabs are not allowed
Open

if ($replacedCount > 0

Spaces must be used to indent lines; tabs are not allowed
Open

$consumed += $bucket->datalen;

Spaces must be used to indent lines; tabs are not allowed
Open

) {

Spaces must be used to indent lines; tabs are not allowed
Open

public $filtername = self::NAME;

Spaces must be used to indent lines; tabs are not allowed
Open

return PSFS_PASS_ON;

Spaces must be used to indent lines; tabs are not allowed
Open

}

Spaces must be used to indent lines; tabs are not allowed
Open

}

Spaces must be used to indent lines; tabs are not allowed
Open

public function filter($in, $out, &$consumed, $closing) {

Spaces must be used to indent lines; tabs are not allowed
Open

&& $this->params['logger'] instanceof LoggerInterface

Spaces must be used to indent lines; tabs are not allowed
Open

public const NAME = 'RTP_skip_commented_lines';

Spaces must be used to indent lines; tabs are not allowed
Open

stream_bucket_append($out, $bucket);

Spaces must be used to indent lines; tabs are not allowed
Open

$replacedCount = 0;

Spaces must be used to indent lines; tabs are not allowed
Open

$bucket->data = preg_replace('/^#.*/mui', '', $bucket->data, -1, $replacedCount);

Spaces must be used to indent lines; tabs are not allowed
Open

&& isset($this->params['logger'])

Spaces must be used to indent lines; tabs are not allowed
Open

}

Spaces must be used to indent lines; tabs are not allowed
Open

$this->params['logger']->debug($replacedCount . ' lines skipped as commented out');

Opening brace should be on a new line
Open

public function filter($in, $out, &$consumed, $closing) {
Category
Status