Completed
Push — master ( eece8c...a3a436 )
by Mr
02:11
created

MatchingSlots   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 44
ccs 0
cts 16
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A search() 0 10 1
A __invoke() 0 11 1
1
<?php
2
3
namespace Bookeo\Endpoints\Availability;
4
5
use Bookeo\Endpoints\Availability;
6
use Bookeo\Models\MatchingSlotList;
7
use Bookeo\Models\MatchingSlotsSearchParameters;
8
9
/**
10
 * Class MatchingSlots
11
 *
12
 * @package Bookeo\Endpoints\Availability
13
 */
14
class MatchingSlots extends Availability
15
{
16
    /**
17
     * Create a search for available slots that match the given search parameters.
18
     * Note that there are two different searches possible, /availability/slots and /availability/matchingslots (this endpoint).
19
     * The former simply shows the number of available seats for each available slot. The latter (this one) takes as input the participant numbers, and shows the slots that are available for those numbers, and an estimate of the price.
20
     * Parameters include product code, number of people and options.
21
     * The successful response also contains a "Location" HTTP header, which can be invoked to navigate the results of the search.
22
     *
23
     * @param MatchingSlotsSearchParameters $search
24
     *
25
     * @return $this
26
     */
27
    public function search(MatchingSlotsSearchParameters $search): self
28
    {
29
        // Set HTTP params
30
        $this->type     = 'post';
31
        $this->endpoint = '/availability/matchingslots' . '?' . $this->getQuery();
32
        $this->params   = $search;
33
        $this->response = MatchingSlotList::class;
0 ignored issues
show
Documentation introduced by
The property response does not exist on object<Bookeo\Endpoints\...lability\MatchingSlots>. 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...
34
35
        return $this;
36
    }
37
38
    /**
39
     * Navigate results of a matching slots search
40
     *
41
     * @param string $pageNavigationToken
42
     * @param int    $pageNumber
43
     *
44
     * @return $this
45
     */
46
    public function __invoke(string $pageNavigationToken, int $pageNumber = 1)
47
    {
48
        $this->appendToQuery('pageNumber', $pageNumber);
49
50
        // Set HTTP params
51
        $this->type     = 'get';
52
        $this->endpoint = '/availability/matchingslots/' . $pageNavigationToken . '?' . $this->getQuery();
53
        $this->response = MatchingSlotList::class;
0 ignored issues
show
Documentation introduced by
The property response does not exist on object<Bookeo\Endpoints\...lability\MatchingSlots>. 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...
54
55
        return $this;
56
    }
57
}
58