Code Duplication    Length = 12-16 lines in 7 locations

src/wormling/phparia/Api/Bridges.php 1 location

@@ 40-51 (lines=12) @@
37
     *
38
     * @return Bridge[]
39
     */
40
    public function getBridges()
41
    {
42
        $uri = 'bridges';
43
        $response = $this->client->getEndpoint()->get($uri);
44
45
        $bridges = [];
46
        foreach (\GuzzleHttp\json_decode($response->getBody()) as $bridge) {
47
            $bridges[] = new Bridge($this->client, $bridge);
48
        }
49
50
        return $bridges;
51
    }
52
53
    /**
54
     * Create a new bridge. This bridge persists until it has been shut down, or Asterisk has been shut down.

src/wormling/phparia/Api/DeviceStates.php 1 location

@@ 49-60 (lines=12) @@
46
     *
47
     * @return DeviceState[]
48
     */
49
    public function getDeviceStates()
50
    {
51
        $uri = 'deviceStates';
52
        $response = $this->client->getEndpoint()->get($uri);
53
54
        $deviceStates = [];
55
        foreach (\GuzzleHttp\json_decode($response->getBody()) as $deviceState) {
56
            $deviceStates[] = new DeviceState($this->client, $deviceState);
57
        }
58
59
        return $deviceStates;
60
    }
61
62
    /**
63
     * Retrieve the current state of a device.

src/wormling/phparia/Api/Endpoints.php 2 locations

@@ 43-54 (lines=12) @@
40
     *
41
     * @return Endpoint
42
     */
43
    public function getEndpoints()
44
    {
45
        $uri = 'endpoints';
46
        $response = $this->client->getEndpoint()->get($uri);
47
48
        $endpoints = [];
49
        foreach (\GuzzleHttp\json_decode($response->getBody()) as $endpoint) {
50
            $endpoints[] = new Endpoint($this->client, $endpoint);
51
        }
52
53
        return $endpoints;
54
    }
55
56
    /**
57
     * Send a message to some technology URI or endpoint.
@@ 89-104 (lines=16) @@
86
     * @return \phparia\Resources\Endpoint[]
87
     * @throws NotFoundException
88
     */
89
    public function getEndpointsByTech($tech)
90
    {
91
        $uri = "endpoints/$tech";
92
        try {
93
            $response = $this->client->getEndpoint()->get($uri);
94
        } catch (RequestException $e) {
95
            $this->processRequestException($e);
96
        }
97
98
        $endpoints = [];
99
        foreach (\GuzzleHttp\json_decode($response->getBody()) as $endpoint) {
100
            $endpoints[] = new Endpoint($this->client, $endpoint);
101
        }
102
103
        return $endpoints;
104
    }
105
106
    /**
107
     * Details for an endpoint.

src/wormling/phparia/Api/Asterisk.php 2 locations

@@ 150-162 (lines=13) @@
147
     *
148
     * @return Module[]
149
     */
150
    public function listModules()
151
    {
152
        $uri = 'asterisk/modules';
153
154
        $response = $this->client->getEndpoint()->get($uri);
155
156
        $modules = [];
157
        foreach (\GuzzleHttp\json_decode($response->getBody()) as $module) {
158
            $modules[] = new Module($module);
159
        }
160
161
        return $modules;
162
    }
163
164
    /**
165
     * Get Asterisk module information.
@@ 230-242 (lines=13) @@
227
     *
228
     * @return LogChannel[]
229
     */
230
    public function listLogChannels()
231
    {
232
        $uri = 'asterisk/logging';
233
234
        $response = $this->client->getEndpoint()->get($uri);
235
236
        $logChannels = [];
237
        foreach (\GuzzleHttp\json_decode($response->getBody()) as $logChannel) {
238
            $logChannels[] = new Module($logChannel);
239
        }
240
241
        return $logChannels;
242
    }
243
244
    /**
245
     * Adds a log channel.

src/wormling/phparia/Api/Channels.php 1 location

@@ 57-68 (lines=12) @@
54
     *
55
     * @return Channel[]
56
     */
57
    public function getChannels()
58
    {
59
        $uri = '/channels';
60
        $response = $this->client->getEndpoint()->get($uri);
61
62
        $channels = [];
63
        foreach (\GuzzleHttp\json_decode($response->getBody()) as $channel) {
64
            $channels[] = new Channel($this->client, $channel);
65
        }
66
67
        return $channels;
68
    }
69
70
    /**
71
     * Create a new channel (originate). The new channel is created immediately and a snapshot of it