Skip to content

Commit c5d5c9a

Browse files
author
Jordan Hall
committed
PSR-2 compliance
1 parent 1fce7e8 commit c5d5c9a

File tree

12 files changed

+519
-507
lines changed

12 files changed

+519
-507
lines changed
Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
1-
<?php
2-
namespace LangleyFoxall\SimpleGoogleMaps\Factories;
3-
4-
use LangleyFoxall\SimpleGoogleMaps\Objects\SimpleGoogleMaps;
5-
6-
abstract class SimpleGoogleMapsFactory
7-
{
8-
public static function getByKey($key)
9-
{
10-
return new SimpleGoogleMaps($key,null,null);
11-
}
12-
13-
public static function getByClientNameAndCryptKey($clientName,$cryptKey)
14-
{
15-
return new SimpleGoogleMaps(null,$clientName,$cryptKey);
16-
}
17-
}
18-
19-
20-
21-
?>
1+
<?php
2+
3+
namespace LangleyFoxall\SimpleGoogleMaps\Factories;
4+
5+
use LangleyFoxall\SimpleGoogleMaps\Objects\SimpleGoogleMaps;
6+
7+
abstract class SimpleGoogleMapsFactory
8+
{
9+
public static function getByKey($key)
10+
{
11+
return new SimpleGoogleMaps($key, null, null);
12+
}
13+
14+
public static function getByClientNameAndCryptKey($clientName, $cryptKey)
15+
{
16+
return new SimpleGoogleMaps(null, $clientName, $cryptKey);
17+
}
18+
}
Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
<?php
2-
namespace LangleyFoxall\SimpleGoogleMaps\Interfaces;
3-
4-
5-
interface ApiAuthInterface
6-
{
7-
public function applyToUrl($url);
8-
}
9-
?>
1+
<?php
2+
3+
namespace LangleyFoxall\SimpleGoogleMaps\Interfaces;
4+
5+
interface ApiAuthInterface
6+
{
7+
public function applyToUrl($url);
8+
}
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
<?php
2+
23
namespace LangleyFoxall\SimpleGoogleMaps\Interfaces;
34

45
interface CacheDriverInterface
56
{
67
public function set($key, $value);
8+
79
public function get($key);
10+
811
public function delete($key);
9-
}
12+
}
Lines changed: 45 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,45 @@
1-
<?php
2-
namespace LangleyFoxall\SimpleGoogleMaps\Objects\ApiAuthDrivers;
3-
4-
use LangleyFoxall\SimpleGoogleMaps\Interfaces\ApiAuthInterface;
5-
use Exception;
6-
7-
/**
8-
* Class BasicApiAuthDriver
9-
* @package LangleyFoxall\SimpleGoogleMaps\Objects\ApiAuthDrivers
10-
*/
11-
class BasicApiAuthDriver implements ApiAuthInterface
12-
{
13-
/**
14-
* @var string API Key
15-
*/
16-
private $key;
17-
18-
/**
19-
* BasicApiAuthDriver constructor.
20-
* @param $key
21-
* @throws Exception
22-
*/
23-
public function __construct($key)
24-
{
25-
if(!$key){
26-
throw new Exception("No key set");
27-
}
28-
$this->key = $key;
29-
}
30-
31-
/**
32-
* @param $url
33-
* @return string
34-
*/
35-
public function applyToUrl($url)
36-
{
37-
$authString= "&key=".$this->key;
38-
$appendedUrl = $url.$authString;
39-
40-
return $appendedUrl;
41-
}
42-
}
43-
44-
?>
1+
<?php
2+
3+
namespace LangleyFoxall\SimpleGoogleMaps\Objects\ApiAuthDrivers;
4+
5+
use Exception;
6+
use LangleyFoxall\SimpleGoogleMaps\Interfaces\ApiAuthInterface;
7+
8+
/**
9+
* Class BasicApiAuthDriver.
10+
*/
11+
class BasicApiAuthDriver implements ApiAuthInterface
12+
{
13+
/**
14+
* @var string API Key
15+
*/
16+
private $key;
17+
18+
/**
19+
* BasicApiAuthDriver constructor.
20+
*
21+
* @param $key
22+
*
23+
* @throws Exception
24+
*/
25+
public function __construct($key)
26+
{
27+
if (!$key) {
28+
throw new Exception('No key set');
29+
}
30+
$this->key = $key;
31+
}
32+
33+
/**
34+
* @param $url
35+
*
36+
* @return string
37+
*/
38+
public function applyToUrl($url)
39+
{
40+
$authString = '&key='.$this->key;
41+
$appendedUrl = $url.$authString;
42+
43+
return $appendedUrl;
44+
}
45+
}
Lines changed: 65 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,65 @@
1-
<?php
2-
namespace LangleyFoxall\SimpleGoogleMaps\Objects\ApiAuthDrivers;
3-
4-
use LangleyFoxall\SimpleGoogleMaps\Interfaces\ApiAuthInterface;
5-
use Exception;
6-
7-
/**
8-
* Class EnterpriseApiAuthDriver
9-
* @package LangleyFoxall\SimpleGoogleMaps\Objects\ApiAuthDrivers
10-
*/
11-
class EnterpriseApiAuthDriver implements ApiAuthInterface
12-
{
13-
/**
14-
* @var string API client name
15-
*/
16-
private $clientName;
17-
/**
18-
* @var string API crypt key
19-
*/
20-
private $cryptKey;
21-
22-
/**
23-
* EnterpriseApiAuthDriver constructor.
24-
* @param $clientName
25-
* @param $cryptKey
26-
* @throws Exception
27-
*/
28-
public function __construct($clientName, $cryptKey)
29-
{
30-
if(!$clientName){
31-
throw new Exception("ClientName not set");
32-
}
33-
34-
if(!$cryptKey){
35-
throw new Exception("CryptKey not set");
36-
}
37-
$this->clientName = $clientName;
38-
$this->cryptKey = $cryptKey;
39-
}
40-
41-
/**
42-
* @param $url
43-
* @return string
44-
*/
45-
public function applyToUrl($url)
46-
{
47-
$urlWithClient = $url."&client=".$this->clientName;
48-
49-
$parsedUrl = parse_url($urlWithClient);
50-
51-
$urlToEncode = $parsedUrl['path'].'?'.$parsedUrl['query'];
52-
$baseKey = base64_decode(str_replace(array('-', '_'), array('+', '/'), $this->cryptKey));
53-
54-
$signature = hash_hmac('sha1', $urlToEncode, $baseKey, true);
55-
56-
$encodedSignature = str_replace(array('+', '/'), array('-', '_'), base64_encode($signature));
57-
58-
$appendedUrl = $urlWithClient."&signature=".$encodedSignature;
59-
60-
return $appendedUrl;
61-
}
62-
}
63-
64-
?>
1+
<?php
2+
3+
namespace LangleyFoxall\SimpleGoogleMaps\Objects\ApiAuthDrivers;
4+
5+
use Exception;
6+
use LangleyFoxall\SimpleGoogleMaps\Interfaces\ApiAuthInterface;
7+
8+
/**
9+
* Class EnterpriseApiAuthDriver.
10+
*/
11+
class EnterpriseApiAuthDriver implements ApiAuthInterface
12+
{
13+
/**
14+
* @var string API client name
15+
*/
16+
private $clientName;
17+
/**
18+
* @var string API crypt key
19+
*/
20+
private $cryptKey;
21+
22+
/**
23+
* EnterpriseApiAuthDriver constructor.
24+
*
25+
* @param $clientName
26+
* @param $cryptKey
27+
*
28+
* @throws Exception
29+
*/
30+
public function __construct($clientName, $cryptKey)
31+
{
32+
if (!$clientName) {
33+
throw new Exception('ClientName not set');
34+
}
35+
36+
if (!$cryptKey) {
37+
throw new Exception('CryptKey not set');
38+
}
39+
$this->clientName = $clientName;
40+
$this->cryptKey = $cryptKey;
41+
}
42+
43+
/**
44+
* @param $url
45+
*
46+
* @return string
47+
*/
48+
public function applyToUrl($url)
49+
{
50+
$urlWithClient = $url.'&client='.$this->clientName;
51+
52+
$parsedUrl = parse_url($urlWithClient);
53+
54+
$urlToEncode = $parsedUrl['path'].'?'.$parsedUrl['query'];
55+
$baseKey = base64_decode(str_replace(['-', '_'], ['+', '/'], $this->cryptKey));
56+
57+
$signature = hash_hmac('sha1', $urlToEncode, $baseKey, true);
58+
59+
$encodedSignature = str_replace(['+', '/'], ['-', '_'], base64_encode($signature));
60+
61+
$appendedUrl = $urlWithClient.'&signature='.$encodedSignature;
62+
63+
return $appendedUrl;
64+
}
65+
}
Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<?php
2+
23
namespace LangleyFoxall\SimpleGoogleMaps\Objects\CacheDrivers;
34

45
use DivineOmega\DOFileCache\DOFileCache;
56
use LangleyFoxall\SimpleGoogleMaps\Interfaces\CacheDriverInterface;
67

78
/**
8-
* Class DOFileCacheDriver
9-
* @package LangleyFoxall\SimpleGoogleMaps\Objects\CacheDrivers
9+
* Class DOFileCacheDriver.
1010
*/
11-
class DOFileCacheDriver implements CacheDriverInterface {
12-
11+
class DOFileCacheDriver implements CacheDriverInterface
12+
{
1313
/**
1414
* @var DOFileCache|null
1515
*/
@@ -22,16 +22,17 @@ public function __construct()
2222
{
2323
$this->cache = new DOFileCache();
2424
$this->cache->changeConfig(
25-
array(
26-
"cacheDirectory" => __DIR__."/../../../cache/",
27-
"gzipCompression" => true
28-
)
25+
[
26+
'cacheDirectory' => __DIR__.'/../../../cache/',
27+
'gzipCompression' => true,
28+
]
2929
);
3030
}
3131

3232
/**
3333
* @param $key
3434
* @param $value
35+
*
3536
* @return bool
3637
*/
3738
public function set($key, $value)
@@ -41,8 +42,10 @@ public function set($key, $value)
4142

4243
/**
4344
* @param $key
44-
* @return mixed
45+
*
4546
* @throws \Exception
47+
*
48+
* @return mixed
4649
*/
4750
public function get($key)
4851
{
@@ -51,10 +54,11 @@ public function get($key)
5154

5255
/**
5356
* @param $key
57+
*
5458
* @return bool
5559
*/
5660
public function delete($key)
5761
{
5862
return $this->cache->delete($key);
5963
}
60-
}
64+
}

src/Objects/Enums/TravelMode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ class TravelMode
88
const WALKING = 'walking';
99
const BICYCLING = 'bicycling';
1010
const TRANSIT = 'transit';
11-
}
11+
}

0 commit comments

Comments
 (0)