diff --git a/RoboFile.php b/RoboFile.php
index 8d483d27..466abc62 100644
--- a/RoboFile.php
+++ b/RoboFile.php
@@ -118,9 +118,7 @@ class RoboFile extends Tasks {
public function docs()
{
$cmd_parts = [
- 'cd build',
- '../vendor/bin/phpdox',
- 'cd ..'
+ 'phpdox',
];
$this->_run($cmd_parts, ' && ');
}
@@ -209,11 +207,6 @@ class RoboFile extends Tasks {
$this->lint();
$this->_run(['phpunit']);
-
- /*$this->taskPHPUnit()
- ->configFile('phpunit.xml')
- ->printed(true)
- ->run();*/
}
/**
diff --git a/build/CodeIgniter/Sniffs/WhiteSpace/LogicalNotSpacingSniff.php b/build/CodeIgniter/Sniffs/WhiteSpace/LogicalNotSpacingSniff.php
index 2e242e4d..f94774cd 100755
--- a/build/CodeIgniter/Sniffs/WhiteSpace/LogicalNotSpacingSniff.php
+++ b/build/CodeIgniter/Sniffs/WhiteSpace/LogicalNotSpacingSniff.php
@@ -65,7 +65,7 @@ class LogicalNotSpacingSniff implements Sniff
$next_token = $tokens[$stackPtr + 1];
if (T_WHITESPACE !== $previous_token['code'] || T_WHITESPACE !== $next_token['code']) {
$error = 'Logical operator ! should always be preceded and followed with a whitespace.';
- $phpcsFile->addError($error, $stackPtr);
+ $phpcsFile->addError($error, $stackPtr, 'badNot');
}
}//end process()
diff --git a/composer.json b/composer.json
index 3dfd8d94..0719d141 100644
--- a/composer.json
+++ b/composer.json
@@ -34,11 +34,11 @@
"require-dev": {
"pdepend/pdepend": "^2.2",
"sebastian/phpcpd": "^3.0",
- "theseer/phpdox": "*",
+ "theseer/phpdox": "0.9.0",
"phploc/phploc": "^3.0",
"phpmd/phpmd": "^2.4",
"phpunit/phpunit": "^6.0",
- "robmorgan/phinx": "^0.6.4",
+ "robmorgan/phinx": "~0.6.4",
"consolidation/robo": "~1.0",
"henrikbjorn/lurker": "^1.1.0",
"symfony/var-dumper": "^3.1",
@@ -47,6 +47,7 @@
"scripts": {
"build:css": "cd public && npm run build && cd ..",
"coverage": "vendor/bin/phpunit -c build",
+ "docs": "vendor/bin/phpdox",
"watch:css": "cd public && npm run watch",
"test": "vendor/bin/phpunit"
}
diff --git a/phpdoc.dist.xml b/phpdoc.dist.xml
index 662d583a..c909515f 100644
--- a/phpdoc.dist.xml
+++ b/phpdoc.dist.xml
@@ -8,11 +8,11 @@
phpdoc
-
+
src
- vendor/aviat/ion/src
- vendor/container-interop/container-interop/src
+
\ No newline at end of file
diff --git a/build/phpdox.xml b/phpdox.xml
similarity index 95%
rename from build/phpdox.xml
rename to phpdox.xml
index 09f85dce..7c27270a 100644
--- a/build/phpdox.xml
+++ b/phpdox.xml
@@ -9,7 +9,7 @@
-
+
@@ -56,12 +56,12 @@
-
+
-
+
@@ -117,10 +117,10 @@
-
-
+
+
diff --git a/src/API/APIRequestBuilder.php b/src/API/APIRequestBuilder.php
index 0c7a309a..485a58ad 100644
--- a/src/API/APIRequestBuilder.php
+++ b/src/API/APIRequestBuilder.php
@@ -207,6 +207,7 @@ class APIRequestBuilder {
*
* @param string $type
* @param string $uri
+ * @throws InvalidArgumentException
* @return self
*/
public function newRequest(string $type, string $uri): self
diff --git a/src/API/FailedResponseException.php b/src/API/FailedResponseException.php
index 3952a13e..ee269d60 100644
--- a/src/API/FailedResponseException.php
+++ b/src/API/FailedResponseException.php
@@ -18,6 +18,9 @@ namespace Aviat\AnimeClient\API;
use UnexpectedValueException;
+/**
+ * Exception for an API Request that fails validation
+ */
class FailedResponseException extends UnexpectedValueException {
}
\ No newline at end of file
diff --git a/src/API/JsonAPI.php b/src/API/JsonAPI.php
index a7545770..e42ad676 100644
--- a/src/API/JsonAPI.php
+++ b/src/API/JsonAPI.php
@@ -27,7 +27,7 @@ class JsonAPI {
* The full data array
*
* Basic structure is generally like so:
- * @example [
+ * [
* 'id' => '12016665',
* 'type' => 'libraryEntries',
* 'links' => [
diff --git a/src/API/Kitsu.php b/src/API/Kitsu.php
index 9ac7bb8c..5ee5f09d 100644
--- a/src/API/Kitsu.php
+++ b/src/API/Kitsu.php
@@ -74,7 +74,7 @@ class Kitsu {
* @param string $endDate
* @return string
*/
- public static function getAiringStatus(string $startDate = null, string $endDate = null): string
+ public static function getAiringStatus(string $startDate = NULL, string $endDate = NULL): string
{
$startAirDate = new DateTimeImmutable($startDate ?? 'tomorrow');
$endAirDate = new DateTimeImmutable($endDate ?? 'next year');
@@ -83,7 +83,7 @@ class Kitsu {
$isDoneAiring = $now > $endAirDate;
$isCurrentlyAiring = ($now > $startAirDate) && ! $isDoneAiring;
- switch (true)
+ switch (TRUE)
{
case $isCurrentlyAiring:
return AnimeAiringStatus::AIRING;
@@ -102,28 +102,28 @@ class Kitsu {
* @param string $hostname
* @return array
*/
- protected static function getServiceMetaData(string $hostname = null): array
+ protected static function getServiceMetaData(string $hostname = NULL): array
{
switch($hostname)
{
case 'www.crunchyroll.com':
return [
'name' => 'Crunchyroll',
- 'link' => true,
+ 'link' => TRUE,
'image' => 'streaming-logos/crunchyroll.svg',
];
case 'www.funimation.com':
return [
'name' => 'Funimation',
- 'link' => true,
+ 'link' => TRUE,
'image' => 'streaming-logos/funimation.svg',
];
case 'www.hulu.com':
return [
'name' => 'Hulu',
- 'link' => true,
+ 'link' => TRUE,
'image' => 'streaming-logos/hulu.svg',
];
@@ -132,7 +132,7 @@ class Kitsu {
default:
return [
'name' => 'Netflix',
- 'link' => false,
+ 'link' => FALSE,
'image' => 'streaming-logos/netflix.svg',
];
}
@@ -172,6 +172,7 @@ class Kitsu {
* Reorganize streaming links for the current list item
*
* @param array $included
+ * @param string $animeId
* @return array
*/
public static function parseListItemStreamingLinks(array $included, string $animeId): array
@@ -235,11 +236,11 @@ class Kitsu {
* @param array $existingTitles
* @return bool
*/
- private static function titleIsUnique(string $title = null, array $existingTitles = []): bool
+ private static function titleIsUnique(string $title = NULL, array $existingTitles = []): bool
{
if (empty($title))
{
- return false;
+ return FALSE;
}
foreach($existingTitles as $existing)
@@ -248,12 +249,12 @@ class Kitsu {
$diff = levenshtein($existing, $title);
$onlydifferentCase = (mb_strtolower($existing) === mb_strtolower($title));
- if ($diff < 3 || $isSubset || $onlydifferentCase)
+ if ($diff < 3 OR $isSubset OR $onlydifferentCase)
{
- return false;
+ return FALSE;
}
}
- return true;
+ return TRUE;
}
}
\ No newline at end of file
diff --git a/src/API/Kitsu/KitsuRequestBuilder.php b/src/API/Kitsu/KitsuRequestBuilder.php
index f26ac4d1..24656fca 100644
--- a/src/API/Kitsu/KitsuRequestBuilder.php
+++ b/src/API/Kitsu/KitsuRequestBuilder.php
@@ -16,8 +16,10 @@
namespace Aviat\AnimeClient\API\Kitsu;
-use Aviat\AnimeClient\API\APIRequestBuilder;
-use Aviat\AnimeClient\API\Kitsu as K;
+use Aviat\AnimeClient\API\{
+ APIRequestBuilder,
+ Kitsu as K
+};
use Aviat\Ion\Json;
class KitsuRequestBuilder extends APIRequestBuilder {
diff --git a/src/API/MAL/MALTrait.php b/src/API/MAL/MALTrait.php
index 65aa580d..939318d9 100644
--- a/src/API/MAL/MALTrait.php
+++ b/src/API/MAL/MALTrait.php
@@ -118,7 +118,7 @@ trait MALTrait {
*/
private function getResponse(string $type, string $url, array $options = [])
{
- $logger = null;
+ $logger = NULL;
if ($this->getContainer())
{
$logger = $this->container->getLogger('mal-request');
@@ -148,7 +148,7 @@ trait MALTrait {
*/
private function request(string $type, string $url, array $options = []): array
{
- $logger = null;
+ $logger = NULL;
if ($this->getContainer())
{
$logger = $this->container->getLogger('mal-request');
@@ -156,7 +156,7 @@ trait MALTrait {
$response = $this->getResponse($type, $url, $options);
- if ((int) $response->getStatus() > 299 || (int) $response->getStatus() < 200)
+ if ((int) $response->getStatus() > 299 OR (int) $response->getStatus() < 200)
{
if ($logger)
{
@@ -170,7 +170,7 @@ trait MALTrait {
/**
* Remove some boilerplate for get requests
*
- * @param array $args
+ * @param mixed ...$args
* @return array
*/
protected function getRequest(...$args): array
@@ -181,12 +181,12 @@ trait MALTrait {
/**
* Remove some boilerplate for post requests
*
- * @param array $args
+ * @param mixed ...$args
* @return array
*/
protected function postRequest(...$args): array
{
- $logger = null;
+ $logger = NULL;
if ($this->getContainer())
{
$logger = $this->container->getLogger('mal-request');
diff --git a/src/API/MAL/Model.php b/src/API/MAL/Model.php
index fa98b110..be306d5a 100644
--- a/src/API/MAL/Model.php
+++ b/src/API/MAL/Model.php
@@ -37,6 +37,8 @@ class Model {
/**
* MAL Model constructor.
+ *
+ * @param ListItem $listItem
*/
public function __construct(ListItem $listItem)
{
diff --git a/src/API/ParallelAPIRequest.php b/src/API/ParallelAPIRequest.php
index 71170738..3d2f974f 100644
--- a/src/API/ParallelAPIRequest.php
+++ b/src/API/ParallelAPIRequest.php
@@ -39,7 +39,7 @@ class ParallelAPIRequest {
* @param string|number $key
* @return self
*/
- public function addRequest($request, $key = null): self
+ public function addRequest($request, $key = NULL): self
{
if ( ! is_null($key))
{
diff --git a/src/API/XML.php b/src/API/XML.php
index a0ba615c..2a697f6d 100644
--- a/src/API/XML.php
+++ b/src/API/XML.php
@@ -39,6 +39,9 @@ class XML {
/**
* XML constructor
+ *
+ * @param string $xml
+ * @param array $data
*/
public function __construct(string $xml = '', array $data = [])
{
@@ -47,6 +50,8 @@ class XML {
/**
* Serialize the data to an xml string
+ *
+ * @return string
*/
public function __toString(): string
{
@@ -67,7 +72,7 @@ class XML {
* Set the data to create xml from
*
* @param array $data
- * @return $this
+ * @return self
*/
public function setData(array $data): self
{
@@ -89,7 +94,7 @@ class XML {
* Set the xml to parse the data from
*
* @param string $xml
- * @return $this
+ * @return self
*/
public function setXML(string $xml): self
{
@@ -161,20 +166,28 @@ class XML {
return static::toXML($this->getData());
}
+ /**
+ * Strip whitespace from raw xml to remove irrelevant text nodes
+ *
+ * @param string $xml
+ * @return string
+ */
private static function stripXMLWhitespace(string $xml): string
{
+
// Get rid of unimportant text nodes by removing
// whitespace characters from between xml tags,
// except for the xml declaration tag, Which looks
// something like:
/* */
+
return preg_replace('/([^\?])>\s+', '$1><', $xml);
}
/**
* Recursively create array structure based on xml structure
*
- * @param array &$root A reference to the current array location
+ * @param array $root A reference to the current array location
* @param DOMNodeList $nodeList The current NodeList object
* @return void
*/
@@ -187,7 +200,7 @@ class XML {
$current =& $root[$el->nodeName];
// It's a top level element!
- if (is_a($el->childNodes->item(0), 'DomText') || ( ! $el->hasChildNodes()))
+ if (is_a($el->childNodes->item(0), 'DomText') OR ( ! $el->hasChildNodes()))
{
$current = $el->textContent;
continue;
diff --git a/src/Command/ClearCache.php b/src/Command/ClearCache.php
index 31dced60..509a98f0 100644
--- a/src/Command/ClearCache.php
+++ b/src/Command/ClearCache.php
@@ -23,6 +23,8 @@ class ClearCache extends BaseCommand {
/**
* Clear the API cache
*
+ * @param array $args
+ * @param array $options
* @return void
* @throws \ConsoleKit\ConsoleException
*/
diff --git a/src/Command/SyncKitsuWithMal.php b/src/Command/SyncKitsuWithMal.php
index 40f5575d..cdb5898d 100644
--- a/src/Command/SyncKitsuWithMal.php
+++ b/src/Command/SyncKitsuWithMal.php
@@ -29,7 +29,16 @@ use Aviat\Ion\Json;
*/
class SyncKitsuWithMal extends BaseCommand {
+ /**
+ * Model for making requests to Kitsu API
+ * @var Aviat\AnimeClient\API\Kitsu
+ */
protected $kitsuModel;
+
+ /**
+ * Model for making requests to MAL API
+ * @var Aviat\AnimeClient\API\MAL
+ */
protected $malModel;
/**
@@ -56,12 +65,11 @@ class SyncKitsuWithMal extends BaseCommand {
$data = $this->diffLists();
$this->echoBox("Number of items that need to be added to MAL: " . count($data));
- if (! empty($data['addToMAL']))
+ if ( ! empty($data['addToMAL']))
{
$this->echoBox("Adding missing list items to MAL");
$this->createMALListItems($data['addToMAL']);
}
-
}
public function getKitsuList()
@@ -80,7 +88,7 @@ class SyncKitsuWithMal extends BaseCommand {
}
$promiseArray = (new Client())->requestMulti($requests);
-
+
$responses = wait(all($promiseArray));
$output = [];
@@ -89,7 +97,7 @@ class SyncKitsuWithMal extends BaseCommand {
$data = Json::decode($response->getBody());
$output = array_merge_recursive($output, $data);
}
-
+
return $output;
}
@@ -113,8 +121,6 @@ class SyncKitsuWithMal extends BaseCommand {
return $output;
}
- // 2015-05-20T23:48:47.731Z
-
public function formatMALList()
{
$orig = $this->getMALList();
@@ -155,7 +161,7 @@ class SyncKitsuWithMal extends BaseCommand {
{
$animeId = $listItem['relationships']['anime']['data']['id'];
$potentialMappings = $includes['anime'][$animeId]['relationships']['mappings'];
- $malId = null;
+ $malId = NULL;
foreach ($potentialMappings as $mappingId)
{
@@ -166,7 +172,7 @@ class SyncKitsuWithMal extends BaseCommand {
}
// Skip to the next item if there isn't a MAL ID
- if ($malId === null)
+ if (is_null($malId))
{
continue;
}
@@ -238,11 +244,11 @@ class SyncKitsuWithMal extends BaseCommand {
$data = $transformer->untransform($item);
$requests[] = $this->malModel->createFullListItem($data);
}
-
+
$promiseArray = (new Client())->requestMulti($requests);
-
+
$responses = wait(all($promiseArray));
-
+
foreach($responses as $key => $response)
{
$id = $itemsToAdd[$key]['mal_id'];
diff --git a/src/Controller.php b/src/Controller.php
index 5ba581c5..55400209 100644
--- a/src/Controller.php
+++ b/src/Controller.php
@@ -369,7 +369,7 @@ class Controller {
{
static $messages;
- if (!$messages)
+ if ( ! $messages)
{
$messages = [];
}
diff --git a/src/Model/API.php b/src/Model/API.php
index 6c6442ee..807b4e02 100644
--- a/src/Model/API.php
+++ b/src/Model/API.php
@@ -26,7 +26,7 @@ class API extends AbstractModel {
*
* @codeCoverageIgnore
* @param array $array
- * @param string $sort_key
+ * @param string $sortKey
* @return void
*/
protected function sortByName(array &$array, string $sortKey)
diff --git a/src/Model/Anime.php b/src/Model/Anime.php
index 969fa5a7..931acb1a 100644
--- a/src/Model/Anime.php
+++ b/src/Model/Anime.php
@@ -48,17 +48,34 @@ class Anime extends API {
AnimeWatchingStatus::COMPLETED => self::COMPLETED,
];
+ /**
+ * Model for making requests to Kitsu API
+ *
+ * @var Aviat\AnimeClient\API\Kitsu\Model
+ */
protected $kitsuModel;
+ /**
+ * Model for making requests to MAL API
+ *
+ * @var Aviat\AnimeClient\API\MAL\Model
+ */
protected $malModel;
+ /**
+ * Whether to use the MAL api
+ *
+ * @var boolean
+ */
protected $useMALAPI;
/**
* Anime constructor.
+ *
* @param ContainerInterface $container
*/
- public function __construct(ContainerInterface $container) {
+ public function __construct(ContainerInterface $container)
+ {
$config = $container->get('config');
$this->kitsuModel = $container->get('kitsu-model');
$this->malModel = $container->get('mal-model');
@@ -193,7 +210,7 @@ class Anime extends API {
* @param string|null $malId
* @return bool
*/
- public function deleteLibraryItem(string $id, string $malId = null): bool
+ public function deleteLibraryItem(string $id, string $malId = NULL): bool
{
$requests = [];
diff --git a/src/Model/Manga.php b/src/Model/Manga.php
index a3f832e1..eaa31f5c 100644
--- a/src/Model/Manga.php
+++ b/src/Model/Manga.php
@@ -44,6 +44,10 @@ class Manga extends API
MangaReadingStatus::COMPLETED => self::COMPLETED
];
+ /**
+ * Maps url segments to their title equivalents
+ * @var array
+ */
protected $statusMap = [
'current' => self::READING,
'planned' => self::PLAN_TO_READ,
@@ -53,10 +57,16 @@ class Manga extends API
];
/**
+ * Model for making requests to Kitsu API
* @var Aviat\AnimeClient\API\Kitsu\KitsuModel
*/
protected $kitsuModel;
+ /**
+ * Constructor
+ *
+ * @param ContainerInterface $container
+ */
public function __construct(ContainerInterface $container)
{
$this->kitsuModel = $container->get('kitsu-model');
diff --git a/src/UrlGenerator.php b/src/UrlGenerator.php
index bb523411..784edd64 100644
--- a/src/UrlGenerator.php
+++ b/src/UrlGenerator.php
@@ -44,9 +44,10 @@ class UrlGenerator extends RoutingBase {
/**
* Get the base url for css/js/images
*
+ * @param string ...$args url segments to apend to the base asset url
* @return string
*/
- public function assetUrl(...$args)
+ public function assetUrl(...$args): string
{
$baseUrl = rtrim($this->url(""), '/');
$baseUrl = "{$baseUrl}" . $this->__get("asset_path");
@@ -62,7 +63,7 @@ class UrlGenerator extends RoutingBase {
* @param string $path
* @return string
*/
- public function url($path)
+ public function url(string $path): string
{
$path = trim($path, '/');
@@ -95,7 +96,7 @@ class UrlGenerator extends RoutingBase {
* @throws InvalidArgumentException
* @return string
*/
- public function defaultUrl($type)
+ public function defaultUrl(string $type): string
{
$type = trim($type);
$defaultPath = $this->__get("default_{$type}_list_path");
@@ -115,9 +116,9 @@ class UrlGenerator extends RoutingBase {
* @param string $type - (optional) The controller (anime or manga), defaults to anime
* @return string
*/
- public function fullUrl($path = "", $type = "anime")
+ public function fullUrl(string $path = "", string $type = "anime"): string
{
- $config_default_route = $this->__get("default_{$type}_path");
+ $configDefaultRoute = $this->__get("default_{$type}_path");
// Remove beginning/trailing slashes
$path = trim($path, '/');
@@ -125,7 +126,7 @@ class UrlGenerator extends RoutingBase {
// Set the default view
if ($path === '')
{
- $path .= trim($config_default_route, '/');
+ $path .= trim($configDefaultRoute, '/');
if ($this->__get('default_to_list_view'))
{
$path .= '/list';