Skip to content

Commit

Permalink
Fix remaining type declarations.
Browse files Browse the repository at this point in the history
  • Loading branch information
geneowak committed Dec 12, 2024
1 parent a98c86f commit 72e5ae2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 19 deletions.
28 changes: 11 additions & 17 deletions App/Html/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ class Parser
{
/**
* Return list of topics data
*
* @param string $html
*/
public static function getTopicsData($html): array
public static function getTopicsData(string $html): array
{
$data = self::getData($html);

Expand All @@ -30,7 +28,7 @@ public static function getTopicsData($html): array
], $data['props']['topics']);
}

public static function getSerieData($serieHtml): array
public static function getSerieData(string $serieHtml): array
{
$data = self::getData($serieHtml);

Expand All @@ -39,10 +37,8 @@ public static function getSerieData($serieHtml): array

/**
* Return full list of series for given topic HTML page.
*
* @param string $html
*/
public static function getSeriesDataFromTopic($html): array
public static function getSeriesDataFromTopic(string $html): array
{
$data = self::getData($html);

Expand Down Expand Up @@ -70,10 +66,9 @@ public static function extractSerieData(array $serie): array
/**
* Return full list of episodes for given series HTML page.
*
* @param string $episodeHtml
* @param number[] $filteredEpisodes
*/
public static function getEpisodesData($episodeHtml, $filteredEpisodes = []): array
public static function getEpisodesData(string $episodeHtml, $filteredEpisodes = []): array
{
$episodes = [];

Expand Down Expand Up @@ -104,30 +99,30 @@ public static function getEpisodesData($episodeHtml, $filteredEpisodes = []): ar
return $episodes;
}

public static function getEpisodeDownloadLink($episodeHtml)
public static function getEpisodeDownloadLink(string $episodeHtml)
{
$data = self::getData($episodeHtml);

return $data['props']['downloadLink'];
}

public static function extractLarabitsSeries($html): array
public static function extractLarabitsSeries(string $html): array
{
$html = str_replace('\/', '/', html_entity_decode((string) $html));
$html = str_replace('\/', '/', html_entity_decode($html));

preg_match_all('"\/series\/([a-z-]+-larabits)"', $html, $matches);

return array_unique($matches[1]);
}

public static function getCsrfToken($html): string
public static function getCsrfToken(string $html): string
{
preg_match('/"csrfToken": \'([^\s]+)\'/', (string) $html, $matches);
preg_match('/"csrfToken": \'([^\s]+)\'/', $html, $matches);

return $matches[1];
}

public static function getUserData($html): array
public static function getUserData(string $html): array
{

$data = self::getData($html);
Expand All @@ -144,10 +139,9 @@ public static function getUserData($html): array
/**
* Returns decoded version of data-page attribute in HTML page
*
* @param string $html
* @return array
*/
private static function getData($html): mixed
private static function getData(string $html): mixed
{
$parser = new Crawler($html);

Expand Down
4 changes: 2 additions & 2 deletions App/Utils/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ public static function write(string $text): void
/**
* Remove specials chars that windows does not support for filenames.
*/
public static function parseEpisodeName($name): ?string
public static function parseEpisodeName(string $name): ?string
{
return preg_replace('/[^A-Za-z0-9\- _]/', '', (string) $name);
return preg_replace('/[^A-Za-z0-9\- _]/', '', $name);
}

/**
Expand Down

0 comments on commit 72e5ae2

Please sign in to comment.