Skip to content

Latest commit

 

History

History
69 lines (50 loc) · 1.67 KB

README.md

File metadata and controls

69 lines (50 loc) · 1.67 KB

php-vnstat

vnstat json output parser for PHP

StyleCI License Total Downloads

Usage

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();
  }
}

Methods

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

Errors/Exceptions

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.