Skip to content

Commit 0a37c7d

Browse files
authored
StatisticManager: Fix types.
1 parent 45abe15 commit 0a37c7d

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/StatisticsManager.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
use Baraja\Doctrine\EntityManager;
99
use Baraja\Doctrine\EntityManagerException;
10+
use Doctrine\ORM\NonUniqueResultException;
11+
use Doctrine\ORM\NoResultException;
1012
use Mathematicator\Statistics\Entity\Sequence;
1113
use Nette\Utils\Strings;
1214
use Nette\Utils\Validators;
@@ -29,13 +31,13 @@ public function __construct(EntityManager $entityManager)
2931

3032
/**
3133
* @param string $query
32-
* @return int[]|float[]
34+
* @return string[]
3335
*/
3436
public function getNumbers(string $query): array
3537
{
3638
$numbers = [];
3739

38-
$query = preg_replace('/[^0-9-.\/]/', ';', $query);
40+
$query = (string) preg_replace('/[^0-9-.\/]/', ';', $query);
3941
$query = (string) preg_replace('/\;+/', ';', $query);
4042

4143
foreach (explode(';', $query) as $number) {
@@ -100,12 +102,13 @@ public function getAverage(array $array)
100102
}
101103

102104
/**
103-
* @param \int[] $sequence
105+
* @param string[] $sequence
104106
* @param int $limit
105107
* @return Sequence[]
106108
*/
107109
public function getSequences(array $sequence, int $limit = 6): array
108110
{
111+
assert(Validators::everyIs($sequence, 'string'));
109112
/** @var Sequence[] $return */
110113
$return = $this->entityManager->getRepository(Sequence::class)
111114
->createQueryBuilder('sequence')
@@ -131,6 +134,8 @@ public function getSequences(array $sequence, int $limit = 6): array
131134
/**
132135
* @param string $aId
133136
* @return Sequence
137+
* @throws EntityManagerException
138+
* @throws NoResultException|NonUniqueResultException
134139
*/
135140
public function getSequence(string $aId): Sequence
136141
{

0 commit comments

Comments
 (0)