Code Duplication    Length = 43-43 lines in 2 locations

Client/ApnsClient.php 1 location

@@ 24-66 (lines=43) @@
21
 * @author  Jamal Youssefi <[email protected]>
22
 * @author  Valentin Coulon <[email protected]>
23
 */
24
class ApnsClient extends BaseApnsClient
25
{
26
    use ClientProfilableTrait;
27
28
    /**
29
     * Constructor.
30
     */
31
    public function __construct()
32
    {
33
        parent::__construct();
34
35
        $this->clientProfiler = new NullClientProfiler();
36
    }
37
38
    /**
39
     * Push a notification to a mobile client.
40
     *
41
     * @param Message $message
42
     *
43
     * @throws \Exception if an Exception is thrown while pushing $message.
44
     */
45
    public function push(Message $message)
46
    {
47
        $profilingEvent = $this->clientProfiler->startProfiling(sprintf('ApnsClient::push(%s)', $message->getPayloadAsJson()));
48
49
        try {
50
            parent::push($message);
51
52
            $this->clientProfiler->stopProfiling($profilingEvent, array(
53
                'error' => false,
54
                'error_message' => null,
55
            ));
56
57
        } catch (\Exception $e) {
58
            $this->clientProfiler->stopProfiling($profilingEvent, array(
59
                'error' => true,
60
                'error_message' => $e->getMessage(),
61
            ));
62
63
            throw $e;
64
        }
65
    }
66
}
67

Client/GcmClient.php 1 location

@@ 24-66 (lines=43) @@
21
 * @author  Jamal Youssefi <[email protected]>
22
 * @author  Valentin Coulon <[email protected]>
23
 */
24
class GcmClient extends BaseGcmClient
25
{
26
    use ClientProfilableTrait;
27
28
    /**
29
     * Constructor.
30
     */
31
    public function __construct()
32
    {
33
        parent::__construct();
34
35
        $this->clientProfiler = new NullClientProfiler();
36
    }
37
38
    /**
39
     * Push a notification to a mobile client.
40
     *
41
     * @param Message $message
42
     *
43
     * @throws \Exception if an Exception is thrown while pushing $message.
44
     */
45
    public function push(Message $message)
46
    {
47
        $profilingEvent = $this->clientProfiler->startProfiling(sprintf('GcmClient::push(%s)', $message->getPayloadAsJson()));
48
49
        try {
50
            parent::push($message);
51
52
            $this->clientProfiler->stopProfiling($profilingEvent, array(
53
                'error' => false,
54
                'error_message' => null,
55
            ));
56
57
        } catch (\Exception $e) {
58
            $this->clientProfiler->stopProfiling($profilingEvent, array(
59
                'error' => true,
60
                'error_message' => $e->getMessage(),
61
            ));
62
63
            throw $e;
64
        }
65
    }
66
}
67