OrderStep_RecordDeviceDetails::HideFromEveryone()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
class OrderStep_RecordDeviceDetails extends OrderStep implements OrderStepInterface
4
{
5
    public function HideFromEveryone()
6
    {
7
        return true;
8
    }
9
10
    private static $defaults = array(
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
11
        'CustomerCanEdit' => 0,
12
        'CustomerCanPay' => 0,
13
        'CustomerCanCancel' => 0,
14
        'Name' => 'Record Device Details',
15
        'Code' => 'RECORD_DEVICE_DETAILS',
16
        'ShowAsInProcessOrder' => 1,
17
    );
18
19
    /**
20
     * The OrderStatusLog that is relevant to the particular step.
21
     *
22
     * @var string
23
     */
24
    protected $relevantLogEntryClassName = 'OrderStatusLog_DeviceDetails';
25
26
    /**
27
     * Can run this step once any items have been submitted.
28
     * makes sure the step is ready to run.... (e.g. check if the order is ready to be emailed as receipt).
29
     * should be able to run this function many times to check if the step is ready.
30
     *
31
     * @see Order::doNextStatus
32
     *
33
     * @param Order object
34
     *
35
     * @return bool - true if the current step is ready to be run...
36
     **/
37
    public function initStep(Order $order)
38
    {
39
        return true;
40
    }
41
42
    /**
43
    *
44
    * @param Order object
45
    *
46
    * @return bool - true if run correctly.
47
    **/
48
    public function doStep(Order $order)
49
    {
50
        $className = $this->getRelevantLogEntryClassName();
51 View Code Duplication
        if (class_exists($className)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
52
            $obj = $className::create();
53
            if (is_a($obj, Object::getCustomClass('OrderStatusLog'))) {
54
                $obj->OrderID = $order->ID;
55
                $obj->Title = $this->Name;
0 ignored issues
show
Documentation introduced by
The property Name does not exist on object<OrderStep_RecordDeviceDetails>. 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...
56
                $obj->write();
57
            }
58
        }
59
        return true;
60
    }
61
62
    /**
63
     * go to next step if order has been submitted.
64
     *
65
     * @param Order $order
66
     *
67
     * @return OrderStep | Null	(next step OrderStep)
0 ignored issues
show
Documentation introduced by
Should the return type not be OrderStep|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
68
     **/
69
    public function nextStep(Order $order)
70
    {
71
        return parent::nextStep($order);
72
    }
73
74
75
    /**
76
     * Explains the current order step.
77
     *
78
     * @return string
79
     */
80
    protected function myDescription()
81
    {
82
        return _t('OrderStep.RECORDDEVICEDETAILS_DESCRIPTION', 'Records the device details of the customer placing the order.');
83
    }
84
}
85