Completed
Pull Request — development (#2540)
by
unknown
02:48
created

Notifications_NotifyMyAndroid   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 40
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getName() 0 3 1
A getParameters() 0 5 1
A notify() 0 17 1
1
<?php
2
	class Notifications_NotifyMyAndroid implements IPushNotification {
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...
3
		
4
		private $apiKey;
5
		public function __construct($apikey){
6
			$this->apiKey = $apikey;
7
		}
8
		
9
		static $priorities = array(
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $priorities.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

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

Loading history...
10
			0 => 'info',
11
			2 => 'error',
12
		);
13
		
14
		public static function getName(){
15
			return  "notifymyandroid.com";
16
		}
17
		
18
		public static function getParameters(){
19
			return array(
20
				'apikey' => 'API key',
21
			);
22
		}
23
		
24
		public function notify($message, $severity = 'info', $event = null){
25
			curl_setopt_array($ch = curl_init(), array(
26
				CURLOPT_URL => "https://www.notifymyandroid.com/publicapi/notify",
27
				CURLOPT_POST => true,
28
				CURLOPT_RETURNTRANSFER => true,
29
				CURLOPT_POSTFIELDS => http_build_query($data = array(
30
					"apikey" => $this->apiKey,
31
					"application" => "CryptoGlance",
32
					"description" => $message,
33
					"content-type" => "text/html",
34
					"event" => $event,
35
					"priority" => array_search($severity, self::$priorities), 
36
				)),
37
			));
38
			curl_exec($ch);
39
			curl_close($ch);
40
		}
41
	}