negundo-client/src/SoftwareConfig.php

32 lines
823 B
PHP
Raw Normal View History

2023-03-29 13:52:15 +00:00
<?php
namespace Negundo\Client;
class SoftwareConfig
{
2023-11-04 00:03:34 +00:00
public string $serverUrl;
2023-03-29 13:52:15 +00:00
2023-11-04 00:03:34 +00:00
public string $softwareHash;
2023-03-29 13:52:15 +00:00
public function __construct(string $softwareHash, string $serverUrl)
{
if (! $softwareHash ) {
throw new \Exception("[Negundo] - You must provide a software hash to match a registered application on the plateform.");
}
else {
$this->softwareHash = $softwareHash;
}
if (! $serverUrl ) {
throw new \Exception("[Negundo] - You must provide a valid Negundo server url endpoint.");
}
else {
$this->serverUrl = $serverUrl;
}
}
public function url(string $path) : string
{
return sprintf("%s/%s/%s", rtrim($this->serverUrl, '/'), $path, $this->softwareHash);
}
}