negundo-client/src/SoftwareConfig.php

32 lines
823 B
PHP

<?php
namespace Negundo\Client;
class SoftwareConfig
{
public string $serverUrl;
public string $softwareHash;
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);
}
}