Skip to content
This repository was archived by the owner on Feb 28, 2024. It is now read-only.

Commit a58b090

Browse files
Merge pull request #3 from Mastercard/feature/fixing-code-smells
Re adding private constructors
2 parents fd3182b + 69841d5 commit a58b090

File tree

5 files changed

+21
-1
lines changed

5 files changed

+21
-1
lines changed

src/Developer/Encryption/FieldLevelEncryption.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
*/
1313
class FieldLevelEncryption {
1414

15+
private function __construct() {
16+
// This class can't be instantiated
17+
}
18+
1519
/**
1620
* Encrypt parts of a JSON payload using the given parameters and configuration.
1721
* @param $payload A JSON string

src/Developer/Encryption/FieldLevelEncryptionConfigBuilder.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
*/
1414
class FieldLevelEncryptionConfigBuilder {
1515

16+
private function __construct() {
17+
// This class can't be instantiated
18+
}
19+
1620
private $encryptionCertificate;
1721
private $encryptionCertificateFingerprint;
1822
private $encryptionKeyFingerprint;

src/Developer/Json/JsonPath.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ class JsonPath {
1616
const FIRST_CHILD_KEY = "/(?:\[')([^\[\]]*)(?:'\])/"; // Returns "obj1" for "$['obj1']['obj2']"
1717
const FIRST_TOKEN_IN_PATH = "/(\['[^\[\]]*'\])/"; // Returns "['obj1']" for "$['obj1']['obj2']"
1818

19+
private function __construct() {
20+
// This class can't be instantiated
21+
}
22+
1923
/**
2024
* Convert the given JSON path to the following form: $['path']['to']['object'].
2125
* @throws \InvalidArgumentException
@@ -53,7 +57,7 @@ static function find($jsonObject, $path) {
5357
$currentElement = $jsonObject;
5458
while ($currentPath !== '$') {
5559
preg_match(self::FIRST_CHILD_KEY, $currentPath, $matches);
56-
if (sizeof($matches).isEmpty()) {
60+
if (empty($matches)) {
5761
return null;
5862
}
5963
$childKey = $matches[1];

src/Developer/Utils/EncodingUtils.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55

66
class EncodingUtils {
77

8+
private function __construct() {
9+
// This class can't be instantiated
10+
}
11+
812
static function encodeBytes($bytes, $encoding) {
913
return $encoding === FieldValueEncoding::HEX ? self::hexEncode($bytes) : base64_encode($bytes);
1014
}

src/Developer/Utils/EncryptionUtils.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ class EncryptionUtils {
1414
const PKCS_8_PEM_HEADER = '-----BEGIN PRIVATE KEY-----';
1515
const PKCS_8_PEM_FOOTER = '-----END PRIVATE KEY-----';
1616

17+
private function __construct() {
18+
// This class can't be instantiated
19+
}
20+
1721
/**
1822
* Create an X.509 resource from the certificate data at the given file path.
1923
* @throws \InvalidArgumentException

0 commit comments

Comments
 (0)