EscolaLMS/topic-types

View on GitHub
src/Helpers/Markdown.php

Summary

Maintainability
A
0 mins
Test Coverage
D
69%

Avoid using static access to class '\Illuminate\Support\Facades\Storage' in method 'convertFilePathByApiPattern'.
Open

            Storage::move($filepath, $destination);
Severity: Minor
Found in src/Helpers/Markdown.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 '\Illuminate\Support\Facades\Storage' in method 'convertFilePathByHttp'.
Open

            if (Storage::exists($destination . '.' . $ext[1])) {
Severity: Minor
Found in src/Helpers/Markdown.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 '\Illuminate\Support\Str' in method 'convertFilePathByHttp'.
Open

        $destination = sprintf($destinationPrefix . '%s', Str::slug(basename($filepath)));
Severity: Minor
Found in src/Helpers/Markdown.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 '\Illuminate\Support\Facades\Storage' in method 'convertFilePathByHttp'.
Open

            $info = getimagesize(Storage::path($destination));
Severity: Minor
Found in src/Helpers/Markdown.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 '\Illuminate\Support\Facades\Storage' in method 'convertFilePathByStorage'.
Open

        Storage::move($filepath, $destination);
Severity: Minor
Found in src/Helpers/Markdown.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 '\Illuminate\Support\Facades\Storage' in method 'convertFilePathByHttp'.
Open

            Storage::copy($destination, $destination . '.' . $ext[1]);
Severity: Minor
Found in src/Helpers/Markdown.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 '\Illuminate\Support\Facades\Storage' in method 'convertFilePathByApiPattern'.
Open

        if (!Storage::exists($destination)) {
Severity: Minor
Found in src/Helpers/Markdown.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 '\Illuminate\Support\Facades\Storage' in method 'convertFilePathByHttp'.
Open

        Storage::put($destination, file_get_contents($filepath));
Severity: Minor
Found in src/Helpers/Markdown.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 '\Illuminate\Support\Facades\Storage' in method 'convertFilePathByHttp'.
Open

                Storage::delete($destination . '.' . $ext[1]);
Severity: Minor
Found in src/Helpers/Markdown.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

A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 20 and the first side effect is on line 8.
Open

<?php
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Possible parse error: class missing opening or closing brace
Open

class Markdown
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Possible parse error: class missing opening or closing brace
Open

class Markdown
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line
Open

    {
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Line exceeds 120 characters; contains 128 characters
Open

                    str_contains($filepath, 'storage') => $results[] = $this->convertFilePathByStorage($filepath, $destination),
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Line exceeds 120 characters; contains 142 characters
Open

                    str_contains($filepath, 'http') => $results[] = $this->convertFilePathByHttp($destinationPrefix, $filepath, $destination),
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Line exceeds 120 characters; contains 158 characters
Open

                    str_contains($filepath, 'api/images/img') => $results[] = $this->convertFilePathByApiPattern($destinationPrefix, $filepath, $destination),
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Line indented incorrectly; expected at least 12 spaces, found 8
Open

        $pathInfo = pathinfo($destination);
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Line indented incorrectly; expected at least 12 spaces, found 8
Open

        $destination = url('api/images/img?path=') . $destination;
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Line indented incorrectly; expected at least 20 spaces, found 16
Open

                $pattern = parse_url($filepath);
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Line indented incorrectly; expected at least 16 spaces, found 12
Open

            return $match[0];
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Line indented incorrectly; expected 0 spaces, found 4
Open

    public const PATH_STRING_NAME = 'path';
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Line indented incorrectly; expected 8 spaces, found 4
Open

    private function convertFilePathByHttp(string $destinationPrefix, string $filepath, string &$destination): array
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Line indented incorrectly; expected 12 spaces, found 8
Open

        }
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Line indented incorrectly; expected 0 spaces, found 4
Open

    public const PASS_STRING_NAME = 'pass';
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Line indented incorrectly; expected 8 spaces, found 4
Open

    private function convertFilePathByApiPattern(
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Line indented incorrectly; expected at least 16 spaces, found 12
Open

            $destination = $destination . '.' . $ext[1];
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Line indented incorrectly; expected at least 20 spaces, found 16
Open

                $destination = $vars['path'];
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Line indented incorrectly; expected 12 spaces, found 8
Open

        }, $input);
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Line indented incorrectly; expected at least 8 spaces, found 4
Open

    {
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Line indented incorrectly; expected 16 spaces, found 12
Open

            }
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Line indented incorrectly; expected 12 spaces, found 16
Open

                if(str_contains($filepath, 'http') && !str_starts_with($filepath, url('/'))) {
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Line indented incorrectly; expected at least 12 spaces, found 8
Open

        $destination = sprintf($destinationPrefix . '%s', Str::slug(basename($filepath)));
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Line indented incorrectly; expected at least 16 spaces, found 12
Open

            $ext = explode('/', $info['mime']);
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Line indented incorrectly; expected 0 spaces, found 4
Open

    public const PORT_STRING_NAME = 'port';
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Line indented incorrectly; expected at least 12 spaces, found 8
Open

        ) {
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Line indented incorrectly; expected at least 16 spaces, found 12
Open

            Storage::copy($destination, $destination . '.' . $ext[1]);
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Line indented incorrectly; expected 8 spaces, found 4
Open

    }
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Line indented incorrectly; expected at least 8 spaces, found 4
Open

    {
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Line indented incorrectly; expected 0 spaces, found 4
Open

    }
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Expected 1 space after IF keyword; 0 found
Open

                if(str_contains($filepath, 'http') && !str_starts_with($filepath, url('/'))) {
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Line indented incorrectly; expected 8 spaces, found 12
Open

            },
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Line indented incorrectly; expected 8 spaces, found 4
Open

    }
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Space before opening parenthesis of function call prohibited
Open

                match (true) {
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Line indented incorrectly; expected 0 spaces, found 4
Open

    public const SCHEME_STRING_NAME = 'scheme';
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Line indented incorrectly; expected 12 spaces, found 20
Open

                    default => $results[] = null,
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Line indented incorrectly; expected 16 spaces, found 12
Open

            if (strpos($filepath, 'api/images/img') !== false) {
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Line indented incorrectly; expected at least 20 spaces, found 16
Open

                return str_replace($match[2], $destination, $match[0]);
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Line indented incorrectly; expected 0 spaces, found 4
Open

    public const FRAGMENT_STRING_NAME = 'fragment';
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Line indented incorrectly; expected 16 spaces, found 12
Open

            }
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Line indented incorrectly; expected 8 spaces, found 4
Open

    public function getImagesPathsWithoutImageApi(string $input): string
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Line indented incorrectly; expected 8 spaces, found 4
Open

    }
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Line indented incorrectly; expected at least 20 spaces, found 16
Open

                parse_str($pattern[self::QUERY_STRING_NAME], $vars);
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Line indented incorrectly; expected 0 spaces, found 4
Open

    public const USER_STRING_NAME = 'user';
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Line indented incorrectly; expected at least 16 spaces, found 12
Open

            $info = getimagesize(Storage::path($destination));
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Line indented incorrectly; expected at least 12 spaces, found 8
Open

        return [$filepath, $destination];
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Closing brace indented incorrectly; expected 4 spaces, found 0
Open

}
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Line indented incorrectly; expected 0 spaces, found 4
Open

    public function convertAssetPaths(string $input, string $destinationPrefix): array
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Line indented incorrectly; expected 8 spaces, found 4
Open

    }
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Line indented incorrectly; expected at least 12 spaces, found 8
Open

        Storage::put($destination, file_get_contents($filepath));
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Line indented incorrectly; expected at least 20 spaces, found 16
Open

                Storage::delete($destination . '.' . $ext[1]);
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Line indented incorrectly; expected 12 spaces, found 8
Open

        if (!array_key_exists(self::EXT_STRING_NAME, $pathInfo) ||
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Line indented incorrectly; expected at least 16 spaces, found 12
Open

            $filepath = $match[2];
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Line indented incorrectly; expected 12 spaces, found 16
Open

                }
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Line indented incorrectly; expected 16 spaces, found 12
Open

            if (Storage::exists($destination . '.' . $ext[1])) {
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Line indented incorrectly; expected 8 spaces, found 4
Open

    private function convertFilePathByStorage(
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Line indented incorrectly; expected at least 12 spaces, found 8
Open

        return preg_replace_callback('/!\[(.*)\]\s?\((.*)()(.*)\)/', function ($match) {
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Line indented incorrectly; expected 0 spaces, found 4
Open

    public const EXT_STRING_NAME = 'extension';
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Line indented incorrectly; expected 0 spaces, found 4
Open

    public const QUERY_STRING_NAME = 'query';
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Line indented incorrectly; expected 0 spaces, found 4
Open

    protected function unParseUrl(array $parsedUrl): string
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Closing brace indented incorrectly; expected 12 spaces, found 4
Open

    }
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

Line indented incorrectly; expected 8 spaces, found 4
Open

    }
Severity: Minor
Found in src/Helpers/Markdown.php by phpcodesniffer

There are no issues that match your filters.

Category
Status