Completed
Push — master ( 2e2112...bbe9e3 )
by Franco
01:17 queued 01:13
created

StubRelatedDocumentExtension   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 3
dl 0
loc 16
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A updateRelatedDocuments() 0 7 1
1
<?php
2
3
class StubRelatedDocumentExtension extends DataExtension implements TestOnly
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
{
5
    /**
6
     * Push a fixed array entry into the datalist for extensibility testing
7
     *
8
     * @param  ArrayList $relatedDocuments
9
     * @return ArrayList
10
     */
11
    public function updateRelatedDocuments(ArrayList $relatedDocuments)
12
    {
13
        $fakeDocument = new DMSDocument;
14
        $fakeDocument->Filename = 'Extended';
0 ignored issues
show
Documentation introduced by
The property Filename does not exist on object<DMSDocument>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
15
        $relatedDocuments->push($fakeDocument);
16
        return $relatedDocuments;
17
    }
18
}
19