Completed
Push — master ( 3e0714...50ebf9 )
by Gabriel
09:17
created

PdfLetter::getMediaFilesystemDisk()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
3
namespace ByTIC\DocumentGenerator\Tests\Fixtures\Models\PdfLetters;
4
5
use ByTIC\DocumentGenerator\PdfLetters\PdfLetterTrait;
6
use ByTIC\MediaLibrary\HasMedia\Interfaces\HasMedia;
7
use Nip\Filesystem\FileDisk;
8
use League\Flysystem\Adapter\Local as LocalAdapter;
9
use Nip\Records\Record;
10
use Nip\Records\Traits\AbstractTrait\RecordTrait as AbstractRecordTrait;
11
12
/**
13
 * Class PdfLetter
14
 * @package ByTIC\DocumentGenerator\Tests\Fixtures\Models\PdfLetters
15
 */
16
class PdfLetter extends Record implements HasMedia
17
{
18
    use PdfLetterTrait;
19
20
    /**
21
     * @return FileDisk
22
     */
23
    public function getMediaFilesystemDisk()
24
    {
25
        if (!isset($this->disk)) {
26
            $this->disk = new FileDisk(
0 ignored issues
show
Documentation introduced by
The property disk does not exist on object<ByTIC\DocumentGen...s\PdfLetters\PdfLetter>. 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...
27
                new LocalAdapter(
28
                    TEST_FIXTURE_PATH
29
                )
30
            );
31
        }
32
        return $this->disk;
0 ignored issues
show
Documentation introduced by
The property disk does not exist on object<ByTIC\DocumentGen...s\PdfLetters\PdfLetter>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read 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.");
        }
    }

}

If the property has read access only, you can use the @property-read 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...
33
    }
34
35
    public function getItemsManager()
36
    {
37
    }
38
39
    /**
40
     * @return AbstractRecordTrait
0 ignored issues
show
Comprehensibility Bug introduced by
The return type AbstractRecordTrait is a trait, and thus cannot be used for type-hinting in PHP. Maybe consider adding an interface and use that for type-hinting?

In PHP traits cannot be used for type-hinting as they do not define a well-defined structure. This is because any class that uses a trait can rename that trait’s methods.

If you would like to return an object that has a guaranteed set of methods, you could create a companion interface that lists these methods explicitly.

Loading history...
41
     */
42
    public function getModelExample()
43
    {
44
        // TODO: Implement getModelExample() method.
45
    }
46
}
47