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): void
public function Vnstat::get(string $interface): \Luna\Vnstat\VnstatResponse
public function Vnstat::getResponse(): \Luna\Vnstat\VnstatResponse
public function Vnstat::setExecutablePath(string $executable): $this
public function Vnstat::getExecutablePath(): string
public function Vnstat::setJson(string $json): $this
public function Vnstat::getJson(): string
Throws 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.