GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

DeleteObjectJob::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
3
namespace Symbiote\QueuedJobs\Jobs;
4
5
use SilverStripe\ORM\DataObject;
6
use Symbiote\QueuedJobs\Services\AbstractQueuedJob;
7
use Symbiote\QueuedJobs\Services\QueuedJob;
8
9
/**
10
 * A job used to delete a data object. Typically used for deletes that need to happen on
11
 * a schedule, or where the delete may have some onflow affect that takes a while to
12
 * finish the deletion.
13
 *
14
 * @author [email protected]
15
 * @license BSD License http://silverstripe.org/bsd-license/
16
 * @skipUpgrade
17
 */
18
class DeleteObjectJob extends AbstractQueuedJob
19
{
20
    /**
21
     * @param DataObject $node
22
     */
23
    public function __construct($node = null)
24
    {
25
        if ($node) {
26
            $this->TargetClass = get_class($node);
0 ignored issues
show
Documentation introduced by
The property TargetClass does not exist on object<Symbiote\QueuedJobs\Jobs\DeleteObjectJob>. 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
            $this->TargetID = $node->ID;
0 ignored issues
show
Documentation introduced by
The property TargetID does not exist on object<Symbiote\QueuedJobs\Jobs\DeleteObjectJob>. 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...
28
            $this->currentStep = 0;
29
            $this->totalSteps = 1;
30
        }
31
    }
32
33
    /**
34
     * @param  string $name
35
     * @return DataObject
36
     */
37
    protected function getObject($name = 'Object')
38
    {
39
        return DataObject::get_by_id($this->TargetClass, $this->TargetID);
0 ignored issues
show
Documentation introduced by
The property TargetClass does not exist on object<Symbiote\QueuedJobs\Jobs\DeleteObjectJob>. 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...
Documentation introduced by
The property TargetID does not exist on object<Symbiote\QueuedJobs\Jobs\DeleteObjectJob>. 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...
40
    }
41
42
    /**
43
     * @return string
44
     */
45
    public function getJobType()
46
    {
47
        return QueuedJob::IMMEDIATE;
48
    }
49
50
    /**
51
     * @return string
52
     */
53
    public function getTitle()
54
    {
55
        $obj = $this->getObject();
56
        if ($obj) {
57
            return _t(__CLASS__ . '.DELETE_OBJ2', 'Delete {title}', array('title' => $obj->Title));
58
        } else {
59
            return _t(__CLASS__ . '.DELETE_JOB', 'Delete node');
60
        }
61
    }
62
63
    public function process()
64
    {
65
        $obj = $this->getObject();
66
        $obj->delete();
67
        $this->currentStep = 1;
68
        $this->isComplete = true;
69
    }
70
}
71