diff --git a/src/Powerdns.php b/src/Powerdns.php index 95f12d3..95b80a3 100644 --- a/src/Powerdns.php +++ b/src/Powerdns.php @@ -215,6 +215,16 @@ public function cryptokeys(string $canonicalDomain): Cryptokey return new Cryptokey($this->connector, $canonicalDomain); } + /** + * Query PowerDNS internal statistics. + * + * @return mixed[] + */ + public function statistics(): array + { + return $this->connector->get('statistics'); + } + /** * Get the PowerDNS server version. * diff --git a/tests/PowerdnsTest.php b/tests/PowerdnsTest.php index cd5078d..00f2149 100644 --- a/tests/PowerdnsTest.php +++ b/tests/PowerdnsTest.php @@ -35,6 +35,23 @@ public function testConfigViaMethods(): void $this->assertSame('test-key', $config['apiKey']); } + public function testStatistics(): void + { + $connector = Mockery::mock(Connector::class); + $connector->shouldReceive('get')->withArgs(['statistics'])->once()->andReturn($example = [ + [ + 'name' => 'corrupt-packets', + 'type' => 'StatisticItem', + 'value' => 0, + ], + ]); + + $powerDns = new Powerdns(null, null, null, null, $connector); + $stats = $powerDns->statistics(); + + self::assertEquals($example, $stats); + } + public function testZone(): void { $connector = Mockery::mock(Connector::class);