-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main'
- Loading branch information
Showing
28 changed files
with
97,572 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"require": { | ||
"php": ">=7.4", | ||
"ext-curl": "*", | ||
"ext-json": "*" | ||
}, | ||
"autoload": { | ||
"classmap": [ | ||
"libs" | ||
] | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
modules/servers/novoserve/libs/cloudrack-type-assettag/.github/workflows/testOnPush.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
on: | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
test_code: | ||
runs-on: ubuntu-latest | ||
name: run unit tests | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Run PHPunit tests | ||
run: cd tests; mkdir output; XDEBUG_MODE=coverage ./phpunit --configuration phpunit.xml --coverage-html output | ||
- name: create results artefact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: test coverage results | ||
path: tests/output/ |
1 change: 1 addition & 0 deletions
1
modules/servers/novoserve/libs/cloudrack-type-assettag/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/.idea |
50 changes: 50 additions & 0 deletions
50
modules/servers/novoserve/libs/cloudrack-type-assettag/AssetTag.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
namespace NovoServe\Cloudrack\Types; | ||
|
||
class AssetTag | ||
{ | ||
/** | ||
* Asset Tag | ||
* @var string | ||
*/ | ||
private $assetTag; | ||
|
||
/** | ||
* ISO-3166 Country Codes | ||
* @link https://en.wikipedia.org/wiki/ISO_3166 | ||
* @var string[] | ||
*/ | ||
private $countryCodes = ['NL', 'DE', 'US', 'DEV']; | ||
|
||
/** | ||
* Validates the asset tag and throws an error if incorrect. | ||
* | ||
* @param string $assetTag The asset tag to validate. | ||
* @throws InvalidAssetTagException | InvalidAssetTagLocationException | ||
*/ | ||
public function __construct(string $assetTag = '') | ||
{ | ||
if (!preg_match('/^((([a-zA-Z]{2,3})-\d{3}-\d{3})|(\d{3}-\d{3}))$/', $assetTag, $pregMatch)) { | ||
throw new InvalidAssetTagException('Invalid asset tag.'); | ||
} | ||
if (!empty($pregMatch[3]) && !in_array($pregMatch[3], $this->countryCodes)) { | ||
throw new InvalidAssetTagLocationException('Invalid asset tag location.'); | ||
} | ||
$this->assetTag = $assetTag; | ||
} | ||
|
||
/** | ||
* Returns the actual string containing the (validated) asset tag. | ||
* | ||
* @return string | ||
*/ | ||
public function __toString(): string | ||
{ | ||
return $this->assetTag; | ||
} | ||
} | ||
|
||
class ServerTag extends AssetTag {} | ||
class InvalidAssetTagException extends \Exception {} | ||
class InvalidAssetTagLocationException extends \Exception {} |
11 changes: 11 additions & 0 deletions
11
modules/servers/novoserve/libs/cloudrack-type-assettag/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# cloudrack-type-assettag | ||
|
||
Data type for AssetTag. Supports the following formats: | ||
``` | ||
123-123 | ||
NL-123-123 | ||
DEV-123-123 | ||
``` | ||
|
||
The prefixes are based on ISO-3166 country codes (except DEV): | ||
https://en.wikipedia.org/wiki/ISO_3166 |
Oops, something went wrong.