Completed
Push — master ( bba0ca...8b0d2a )
by Mr
02:55
created

Holds::delete()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 0
cts 6
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Bookeo\Endpoints;
4
5
use Bookeo\Client;
6
use Bookeo\Interfaces\QueryInterface;
7
use Bookeo\Models\Hold;
8
use Bookeo\Models\HoldCreate;
9
10
/**
11
 * Access account settings
12
 *
13
 * @package Bookeo\Endpoints
14
 */
15
class Holds extends Client
16
{
17
    /**
18
     * Retrieve a hold previously generated
19
     *
20
     * @param string $hold_id
21
     *
22
     * @return $this
23
     */
24
    public function __invoke(string $hold_id)
25
    {
26
        $this->hold_id = $hold_id;
0 ignored issues
show
Documentation introduced by
The property hold_id does not exist on object<Bookeo\Endpoints\Holds>. 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
28
        // Set HTTP params
29
        $this->type     = 'get';
30
        $this->endpoint = '/holds/' . $hold_id . '?' . $this->getQuery();
31
        $this->response = Hold::class;
0 ignored issues
show
Documentation introduced by
The property response does not exist on object<Bookeo\Endpoints\Holds>. 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...
32
33
        return $this;
34
    }
35
36
    /**
37
     * Create a temporary hold to finalize the booking
38
     *
39
     * Performs a final check of the booking, and reserves required resources/seats to allow finalization of the booking process (ex. process payment).
40
     * The returned object also contains the updated price calculations.
41
     * Normally your application should have no more than one hold in place during a customer booking process.
42
     * Make sure to not leave many holds around. In any case, holds are deleted automatically after a fixed time from creation.
43
     * Note that when creating a hold, the customer field of the booking can be missing, in which case Bookeo will assume a default customer coming from the same country as the account.
44
     * The successful response also contains a "Location" HTTP header, which can be used to access the created resource in future invocations.
45
     *
46
     * @param \Bookeo\Models\HoldCreate $create
47
     *
48
     * @return \Bookeo\Interfaces\QueryInterface
49
     */
50
    public function create(HoldCreate $create): QueryInterface
0 ignored issues
show
Unused Code introduced by
The parameter $create is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
51
    {
52
        // Set HTTP params
53
        $this->type     = 'post';
54
        $this->endpoint = '/holds?' . $this->getQuery();
55
        $this->response = Hold::class;
0 ignored issues
show
Documentation introduced by
The property response does not exist on object<Bookeo\Endpoints\Holds>. 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
57
        return $this;
58
    }
59
60
    /**
61
     * Delete a temporary hold
62
     *
63
     * Delete a temporary hold previously created.
64
     * Note that you can also delete a hold when creating a new hold (ex. when the customer goes back in the booking process and selects a different time), or when creating a booking (i.e. when the customer checks out), without having to make a separate call to this endpoint.
65
     *
66
     * @return \Bookeo\Interfaces\QueryInterface
67
     */
68
    public function delete(): QueryInterface
69
    {
70
        // Set HTTP params
71
        $this->type     = 'delete';
72
        $this->endpoint = '/holds/' . $this->hold_id . '?' . $this->getQuery();
0 ignored issues
show
Documentation introduced by
The property hold_id does not exist on object<Bookeo\Endpoints\Holds>. 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...
73
74
        return $this;
75
    }
76
}
77