vnstat json output parser for PHP
use Luna\Vnstat\Vnstat;
class YourClass extends Awesomeness implements Ideas
{
protected $interface = 'eth0';
public function runWithStaticMethod()
{
$jsonObject = Vnstat::get($this->interface);
}
public function runWithNewInstance()
{
$vnstat = new Vnstat($this->interface);
$vnstat->run();
$rawJson = $vnstat->getJson();
$response = $vnstat->getResponse();
}
}public function Vnstat::__construct(string $interface): voidpublic function Vnstat::get(string $interface): \Luna\Vnstat\VnstatResponsepublic function Vnstat::getResponse(): \Luna\Vnstat\VnstatResponsepublic function Vnstat::setExecutablePath(string $executable): $thispublic function Vnstat::getExecutablePath(): stringpublic function Vnstat::setJson(string $json): $thispublic function Vnstat::getJson(): stringThrows Luna\Vnstat\Exceptions\InvalidJsonException if the string returned by Vnstat::getJson() was an invalid json string.
Throws Luna\Vnstat\Exceptions\ExecutableNotFoundException if which vnstat failed.
Throws \Symfony\Component\Process\Exception\ProcessFailedException if vnstat --query --json -i $interface failed.