From 5d4a9c89673aadf76572e638445f67dd976bb177 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Belin?= Date: Wed, 13 Mar 2019 14:06:30 +0100 Subject: [PATCH] Better validation of counters --- lib/models/Repository.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/models/Repository.php b/lib/models/Repository.php index 2302187..b8b4cf3 100644 --- a/lib/models/Repository.php +++ b/lib/models/Repository.php @@ -457,7 +457,7 @@ class Repository implements \JsonSerializable { * @return $this This instance. */ function setForksCount(int $value): self { - $this->forksCount = $value; + $this->forksCount = max(0, $value); return $this; } @@ -507,7 +507,7 @@ class Repository implements \JsonSerializable { * @return $this This instance. */ function setOpenIssuesCount(int $value): self { - $this->openIssuesCount = $value; + $this->openIssuesCount = max(0, $value); return $this; } @@ -577,7 +577,7 @@ class Repository implements \JsonSerializable { * @return $this This instance. */ function setStarsCount(int $value): self { - $this->starsCount = $value; + $this->starsCount = max(0, $value); return $this; } @@ -597,7 +597,7 @@ class Repository implements \JsonSerializable { * @return $this This instance. */ function setWatchersCount(int $value): self { - $this->watchersCount = $value; + $this->watchersCount = max(0, $value); return $this; }