diff --git a/phpunit.xml.dist b/phpunit.xml.dist index b99df7e..0263dbb 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -4,6 +4,9 @@ + + src + diff --git a/src/ActivityPhp/Server.php b/src/ActivityPhp/Server.php index d0da9ee..1b2fe18 100644 --- a/src/ActivityPhp/Server.php +++ b/src/ActivityPhp/Server.php @@ -113,14 +113,12 @@ public function inbox(string $handle): Inbox { $this->logger()->info($handle . ':' . __METHOD__); - if (isset($this->inboxes[$handle])) { - return $this->inboxes[$handle]; - } - - // Build actor - $actor = $this->actor($handle); + if (! isset($this->inboxes[$handle])) { + // Build actor + $actor = $this->actor($handle); - $this->inboxes[$handle] = new Inbox($actor, $this); + $this->inboxes[$handle] = new Inbox($actor, $this); + } return $this->inboxes[$handle]; } @@ -133,14 +131,12 @@ public function outbox(string $handle): Outbox { $this->logger()->info($handle . ':' . __METHOD__); - if (isset($this->outboxes[$handle])) { - return $this->outboxes[$handle]; - } + if (! isset($this->outboxes[$handle])) { + // Build actor + $actor = $this->actor($handle); - // Build actor - $actor = $this->actor($handle); - - $this->outboxes[$handle] = new Outbox($actor, $this); + $this->outboxes[$handle] = new Outbox($actor, $this); + } return $this->outboxes[$handle]; } @@ -152,12 +148,10 @@ public function actor(string $handle): Actor { $this->logger()->info($handle . ':' . __METHOD__); - if (isset($this->actors[$handle])) { - return $this->actors[$handle]; + if (! isset($this->actors[$handle])) { + $this->actors[$handle] = new Actor($handle, $this); } - $this->actors[$handle] = new Actor($handle, $this); - return $this->actors[$handle]; } diff --git a/src/ActivityPhp/Version.php b/src/ActivityPhp/Version.php index 7f7d825..fd4a779 100644 --- a/src/ActivityPhp/Version.php +++ b/src/ActivityPhp/Version.php @@ -13,6 +13,8 @@ namespace ActivityPhp; +use Exception; + /** * \ActivityPhp\Version handles current version of this package */ @@ -49,22 +51,13 @@ public static function getRootNamespace(): string } /** - * Check that given filename is a string and is readable + * Check that given filename is a readable file * - * @throws \Exception if filename is not a string - * or if filename is not a file + * @throws \Exception if filename is not a file * or if file is not readable */ public static function checkFile(string $filename): void { - // Must be a string - if (! is_string($filename)) { - throw new Exception( - 'FILE_ERROR Filename must be a string. Given: ' - . gettype($filename) - ); - } - // Must be readable if (! is_readable($filename)) { throw new Exception(