keboola/php-csv

View on GitHub
src/CsvReader.php

Summary

Maintainability
A
0 mins
Test Coverage
A
96%

Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
Wontfix

        $file,
        $delimiter = CsvOptions::DEFAULT_DELIMITER,
        $enclosure = CsvOptions::DEFAULT_ENCLOSURE,
        $escapedBy = CsvOptions::DEFAULT_ESCAPED_BY,
        $skipLines = 0
Severity: Minor
Found in src/CsvReader.php - About 35 mins to fix

    Remove error control operator '@' on line 127.
    Open

        protected function detectLineBreak()
        {
            @rewind($this->getFilePointer());
            $sample = @fread($this->getFilePointer(), self::SAMPLE_SIZE);
            if (substr((string) $sample, -1) === "\r") {
    Severity: Minor
    Found in src/CsvReader.php by phpmd

    ErrorControlOperator

    Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.

    Example

    function foo($filePath) {
        $file = @fopen($filPath); // hides exceptions
        $key = @$array[$notExistingKey]; // assigns null to $key
    }

    Source http://phpmd.org/rules/cleancode.html#errorcontroloperator

    Remove error control operator '@' on line 148.
    Open

        protected function readLine()
        {
            // allow empty enclosure hack
            $enclosure = !$this->getEnclosure() ? chr(0) : $this->getEnclosure();
            $escapedBy = !$this->getEscapedBy() ? chr(0) : $this->getEscapedBy();
    Severity: Minor
    Found in src/CsvReader.php by phpmd

    ErrorControlOperator

    Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.

    Example

    function foo($filePath) {
        $file = @fopen($filPath); // hides exceptions
        $key = @$array[$notExistingKey]; // assigns null to $key
    }

    Source http://phpmd.org/rules/cleancode.html#errorcontroloperator

    Remove error control operator '@' on line 132.
    Open

        protected function detectLineBreak()
        {
            @rewind($this->getFilePointer());
            $sample = @fread($this->getFilePointer(), self::SAMPLE_SIZE);
            if (substr((string) $sample, -1) === "\r") {
    Severity: Minor
    Found in src/CsvReader.php by phpmd

    ErrorControlOperator

    Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.

    Example

    function foo($filePath) {
        $file = @fopen($filPath); // hides exceptions
        $key = @$array[$notExistingKey]; // assigns null to $key
    }

    Source http://phpmd.org/rules/cleancode.html#errorcontroloperator

    Remove error control operator '@' on line 113.
    Open

        protected function openCsvFile($fileName)
        {
            if (!is_file($fileName)) {
                throw new Exception(
                    'Cannot open file ' . $fileName,
    Severity: Minor
    Found in src/CsvReader.php by phpmd

    ErrorControlOperator

    Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.

    Example

    function foo($filePath) {
        $file = @fopen($filPath); // hides exceptions
        $key = @$array[$notExistingKey]; // assigns null to $key
    }

    Source http://phpmd.org/rules/cleancode.html#errorcontroloperator

    Remove error control operator '@' on line 131.
    Open

        protected function detectLineBreak()
        {
            @rewind($this->getFilePointer());
            $sample = @fread($this->getFilePointer(), self::SAMPLE_SIZE);
            if (substr((string) $sample, -1) === "\r") {
    Severity: Minor
    Found in src/CsvReader.php by phpmd

    ErrorControlOperator

    Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.

    Example

    function foo($filePath) {
        $file = @fopen($filPath); // hides exceptions
        $key = @$array[$notExistingKey]; // assigns null to $key
    }

    Source http://phpmd.org/rules/cleancode.html#errorcontroloperator

    Remove error control operator '@' on line 128.
    Open

        protected function detectLineBreak()
        {
            @rewind($this->getFilePointer());
            $sample = @fread($this->getFilePointer(), self::SAMPLE_SIZE);
            if (substr((string) $sample, -1) === "\r") {
    Severity: Minor
    Found in src/CsvReader.php by phpmd

    ErrorControlOperator

    Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.

    Example

    function foo($filePath) {
        $file = @fopen($filPath); // hides exceptions
        $key = @$array[$notExistingKey]; // assigns null to $key
    }

    Source http://phpmd.org/rules/cleancode.html#errorcontroloperator

    Avoid using static access to class 'Keboola\Csv\LineBreaksHelper' in method 'detectLineBreak'.
    Open

            return LineBreaksHelper::detectLineBreaks($sample, $this->getEnclosure(), $this->getEscapedBy());
    Severity: Minor
    Found in src/CsvReader.php by phpmd

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

    Source https://phpmd.org/rules/cleancode.html#staticaccess

    Avoid using static access to class 'Keboola\Csv\UTF8BOMHelper' in method '__construct'.
    Open

            $header = UTF8BOMHelper::detectAndRemoveBOM($this->readLine());
    Severity: Minor
    Found in src/CsvReader.php by phpmd

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

    Source https://phpmd.org/rules/cleancode.html#staticaccess

    There are no issues that match your filters.

    Category
    Status