NewPayloadData   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 7
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 1
c 2
b 0
f 1
lcom 0
cbo 1
dl 0
loc 7
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getDataFields() 0 5 1
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 29 and the first side effect is on line 22.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/**
3
 * Copyright 2015 Alexey Maslov <[email protected]>
4
 *
5
 * Licensed under the Apache License, Version 2.0 (the "License");
6
 * you may not use this file except in compliance with the License.
7
 * You may obtain a copy of the License at
8
 *
9
 * http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 *
17
 * GCM message sending example
18
 * @author alxmsl
19
 * @date 5/28/13
20
 */
21
22
include '../vendor/autoload.php';
23
24
use alxmsl\Google\GCM\Client;
25
use alxmsl\Google\GCM\Message\PayloadData;
26
use alxmsl\Google\GCM\Message\PayloadMessage;
27
28
// Create new payload class
29
final class NewPayloadData extends PayloadData {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
30
    protected function getDataFields() {
31
        return array(
32
            'test' => 'test_01',
33
        );
34
    }
35
}
36
37
// Create payload instance
38
$Data = new NewPayloadData();
39
40
// Create and initialize message instance
41
$Message = new PayloadMessage();
42
$Message->setRegistrationIds('DeV1CeT0kEN')
43
    ->setType(PayloadMessage::TYPE_JSON)
44
    ->setData($Data);
45
46
// Create GCM client
47
$Client = new Client();
48
$Client->getRequest()->setConnectTimeout(60);
49
$Client->setAuthorizationKey('aUTH0R1Z4t1oNKEy');
50
51
// ...and send the message
52
$Response = $Client->send($Message);
53
var_dump($Response);
0 ignored issues
show
Security Debugging Code introduced by
var_dump($Response); looks like debug code. Are you sure you do not want to remove it? This might expose sensitive data.
Loading history...
54