Skip to content

Commit 16faaaa

Browse files
committed
SecureNative class static
1 parent d473934 commit 16faaaa

1 file changed

Lines changed: 19 additions & 19 deletions

File tree

src/securenative.php

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,39 +11,39 @@
1111

1212
class SecureNative
1313
{
14-
public $apiKey;
15-
private $options;
16-
private $eventManager;
14+
private static $apiKey;
15+
private static $options;
16+
private static $eventManager;
1717

18-
public function __construct($apiKey, SecureNativeOptions $secureNativeOptions)
18+
public static function init($apiKey, SecureNativeOptions $secureNativeOptions)
1919
{
2020
if ($apiKey == '') {
2121
throw new Exception('You must pass your SecureNative api key');
2222
}
2323

24-
$this->apiKey = $apiKey;
25-
$this->options = $secureNativeOptions;
26-
$this->eventManager = new EventManager($apiKey, $this->options);
24+
self::$apiKey = $apiKey;
25+
self::$options = $secureNativeOptions;
26+
self::$eventManager = new EventManager($apiKey, self::$options);
2727
}
2828

29-
public function track(Array $attributes)
29+
public static function track(Array $attributes)
3030
{
3131
$opts = new EventOptions(json_encode($attributes));
3232
if (count($opts->params) > MAX_CUSTOM_PARAMS) {
3333
throw new Exception(sprintf('You can only specify maximum of %d params', MAX_CUSTOM_PARAMS));
3434
}
3535

36-
$requestUrl = sprintf('%s/track', $this->options->getApiUrl());
37-
$event = $this->eventManager->buildEvent($opts);
38-
$this->eventManager->sendAsync($event, $requestUrl);
36+
$requestUrl = sprintf('%s/track', self::$options->getApiUrl());
37+
$event = self::$eventManager->buildEvent($opts);
38+
self::$eventManager->sendAsync($event, $requestUrl);
3939
}
4040

41-
public function verify(Array $attributes)
41+
public static function verify(Array $attributes)
4242
{
4343
$opts = new EventOptions(json_encode($attributes));
44-
$requestUrl = sprintf('%s/verify', $this->options->getApiUrl());
45-
$event = $this->eventManager->buildEvent($opts);
46-
$result = $this->eventManager->sendSync($event, $requestUrl);
44+
$requestUrl = sprintf('%s/verify', self::$options->getApiUrl());
45+
$event = self::$eventManager->buildEvent($opts);
46+
$result = self::$eventManager->sendSync($event, $requestUrl);
4747

4848
if($result == null){
4949
return new VerifyResult();
@@ -52,11 +52,11 @@ public function verify(Array $attributes)
5252
return $result;
5353
}
5454

55-
public function flow($flowId, Array $attributes)
55+
public static function flow($flowId, Array $attributes)
5656
{
5757
$opts = new EventOptions(json_encode($attributes));
58-
$requestUrl = sprintf('%s/flow/%s', $this->options->getApiUrl(), $flowId);
59-
$event = $this->eventManager->buildEvent($opts);
60-
return $this->eventManager->sendSync($event, $requestUrl);
58+
$requestUrl = sprintf('%s/flow/%s', self::$options->getApiUrl(), $flowId);
59+
$event = self::$eventManager->buildEvent($opts);
60+
return self::$eventManager->sendSync($event, $requestUrl);
6161
}
6262
}

0 commit comments

Comments
 (0)