Code Duplication    Length = 32-32 lines in 2 locations

src/Api/ApplicationsApi.php 1 location

@@ 19-50 (lines=32) @@
16
/**
17
 * Class ApplicationsApi.
18
 */
19
class ApplicationsApi extends AbstractApi
20
{
21
    /**
22
     * @return \Fnayou\InstapushPHP\Model\Applications
23
     */
24
    public function list()
25
    {
26
        $applicationsApi = $this->doGet('/apps/list');
27
28
        // full absurdity
29
        if ('null' === $applicationsApi->getResponse()->getBody()->__toString()) {
30
            return new Applications();
31
        }
32
33
        return $this->transformResponse(Applications::class);
34
    }
35
36
    /**
37
     * @param \Fnayou\InstapushPHP\Model\Application $application
38
     *
39
     * @return \Fnayou\InstapushPHP\Model\Application
40
     */
41
    public function add(Application $application)
42
    {
43
        $this->doPost('/apps/add', $application->toArray());
44
45
        /** @var \Fnayou\InstapushPHP\Model\Applications $applications */
46
        $applications = $this->list();
47
48
        return $applications->last();
49
    }
50
}
51

src/Api/EventsApi.php 1 location

@@ 19-50 (lines=32) @@
16
/**
17
 * Class EventsApi.
18
 */
19
class EventsApi extends AbstractApi
20
{
21
    /**
22
     * @return \Fnayou\InstapushPHP\Model\Events
23
     */
24
    public function list()
25
    {
26
        $eventsApi = $this->doGet('/events/list');
27
28
        // full absurdity
29
        if ('null' === $eventsApi->getResponse()->getBody()->__toString()) {
30
            return new Events();
31
        }
32
33
        return $eventsApi->transformResponse(Events::class);
34
    }
35
36
    /**
37
     * @param \Fnayou\InstapushPHP\Model\Event $event
38
     *
39
     * @return \Fnayou\InstapushPHP\Model\Event
40
     */
41
    public function add(Event $event)
42
    {
43
        $this->doPost('/events/add', $event->toArray());
44
45
        /** @var \Fnayou\InstapushPHP\Model\Events $events */
46
        $events = $this->list();
47
48
        return $events->last();
49
    }
50
}
51