lib/Ajde/Embed/Vimeo.php

Summary

Maintainability
A
0 mins
Test Coverage

Missing class import via use statement (line '43', column '54').
Open

                Ajde_Exception_Log::logException(new Ajde_Exception('Could not parse result from Vimeo'));
Severity: Minor
Found in lib/Ajde/Embed/Vimeo.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

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

The method _getVimeoId uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $matches = [];
            preg_match('%video/([0-9]+?)[\/\?\"]%', $this->_code, $matches);

            return isset($matches[1]) ? $matches[1] : null;
Severity: Minor
Found in lib/Ajde/Embed/Vimeo.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

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

Avoid using static access to class 'Ajde_Http_Curl' in method 'getThumbnail'.
Open

            $response = Ajde_Http_Curl::get("http://vimeo.com/api/v2/video/$vmid.php");
Severity: Minor
Found in lib/Ajde/Embed/Vimeo.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 'Ajde_Exception_Log' in method 'getThumbnail'.
Open

                Ajde_Exception_Log::logException(new Ajde_Exception('Could not parse result from Vimeo'));
Severity: Minor
Found in lib/Ajde/Embed/Vimeo.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

The class Ajde_Embed_Vimeo is not named in CamelCase.
Open

class Ajde_Embed_Vimeo extends Ajde_Embed
{
    public function convertUrlToEmbed()
    {
        if (substr($this->_code, 0, 7) == 'http://' || substr($this->_code, 0, 8) == 'https://') {
Severity: Minor
Found in lib/Ajde/Embed/Vimeo.php by phpmd

CamelCaseClassName

Since: 0.2

It is considered best practice to use the CamelCase notation to name classes.

Example

class class_name {
}

Source

The method _getVimeoId is not named in camelCase.
Open

    private function _getVimeoId()
    {
        if (substr($this->_code, 0, 7) == 'http://' || substr($this->_code, 0, 8) == 'https://') {
            return str_replace('/', '', parse_url($this->_code, PHP_URL_PATH));
        } else {
Severity: Minor
Found in lib/Ajde/Embed/Vimeo.php by phpmd

CamelCaseMethodName

Since: 0.2

It is considered best practice to use the camelCase notation to name methods.

Example

class ClassName {
    public function get_name() {
    }
}

Source

There are no issues that match your filters.

Category
Status