Skip to content

Commit

Permalink
Merge pull request #4 from alkaupp/master
Browse files Browse the repository at this point in the history
Add PHP7 type hints and strict declarations
  • Loading branch information
lasselehtinen authored Jan 29, 2018
2 parents f62139f + 82a12a5 commit 1741e3a
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 116 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/vendor
composer.lock
.idea/
27 changes: 16 additions & 11 deletions src/Bookmarks.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php
declare(strict_types=1);

namespace lasselehtinen\Issuu;

use stdClass;

class Bookmarks
{
/**
* Issuu instance
* @var Issuu
*/
/** @var Issuu */
private $issuu;

public function __construct(Issuu $issuu)
Expand All @@ -22,9 +22,9 @@ public function __construct(Issuu $issuu)
* @param string $name Name of the document
* @param integer $page Page in document to bookmark. Default is page 1
* @param string $folderIds Folder to add this bookmark to. If no value is submitted the bookmark will not be added to any folder
* @return object
* @return stdClass
*/
public function add($documentUsername, $name, $page = 1, $folderIds = null)
public function add(string $documentUsername, string $name, int $page = 1, string $folderIds = null): stdClass
{
$query = [
'action' => 'issuu.bookmarks.list',
Expand All @@ -49,10 +49,16 @@ public function add($documentUsername, $name, $page = 1, $folderIds = null)
* @param integer $pageIndex Maximum number of documents to be returned. Value must be between 0 - 30. Default is 10.
* @param string $bookmarkSortBy Response parameter to sort the result by. Sorting can only be done on a single parameter. Default is no particular sort order.
* @param string $responseParams Comma-separated list of Response parameter to be returned. If no value is submitted all parameters will be returned
* @return object
* @return stdClass
*/
public function list($folderId = null, $resultOrder = 'asc', $startIndex = 0, $pageIndex = 10, $bookmarkSortBy = null, $responseParams = null)
{
public function list(
string $folderId = null,
string $resultOrder = 'asc',
int $startIndex = 0,
int $pageIndex = 10,
int $bookmarkSortBy = null,
int $responseParams = null
): stdClass {
$query = [
'action' => 'issuu.bookmarks.list',
'folderId' => $folderId,
Expand All @@ -74,14 +80,13 @@ public function list($folderId = null, $resultOrder = 'asc', $startIndex = 0, $p
* @param string $bookmarkIds
* @return string
*/
public function delete($bookmarkIds)
public function delete(string $bookmarkIds): string
{
$query = [
'action' => 'issuu.bookmarks.delete',
'bookmarkIds' => $bookmarkIds,
];

// Perform query
$bookmarks = $this->issuu->getResponse($query);

return $bookmarks->rsp->stat;
Expand Down
128 changes: 62 additions & 66 deletions src/Documents.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
<?php
declare(strict_types=1);

namespace lasselehtinen\Issuu;

use lasselehtinen\Issuu\Exceptions\FileDoesNotExist;
use stdClass;

class Documents
{
/**
* Issuu instance
* @var Issuu
*/
/** @var Issuu */
private $issuu;

public function __construct(Issuu $issuu)
Expand All @@ -36,26 +35,26 @@ public function __construct(Issuu $issuu)
* @param boolean $ratingAllowed Can other people rate this document?
* @param string $publishDate Datetime when this document was originally published. Default is at the time of upload. See http://developers.issuu.com/managing-your-publications/date-and-time-formats/ for formatting rules
* @param string $folderIds Folders to copy the document to when processing is done. Use method Folders list to find the id of a specific folder - See http://developers.issuu.com/managing-your-publications/folders/list/
* @return object
* @return stdClass
*/
public function upload(
$file,
$name = null,
$title = null,
$tags = null,
$commentsAllowed = true,
$description = null,
$downloadable = false,
$infoLink = null,
$language = null,
$access = 'public',
$explicit = false,
$category = null,
$type = null,
$ratingAllowed = true,
$publishDate = null,
$folderIds = null
) {
string $file,
string $name = null,
string $title = null,
string $tags = null,
bool $commentsAllowed = true,
string $description = null,
bool $downloadable = false,
string $infoLink = null,
string $language = null,
string $access = 'public',
bool $explicit = false,
string $category = null,
string $type = null,
bool $ratingAllowed = true,
string $publishDate = null,
string $folderIds = null
): stdClass {
// Check that file exists
if (!file_exists($file)) {
throw new FileDoesNotExist();
Expand Down Expand Up @@ -106,26 +105,26 @@ public function upload(
* @param boolean $ratingAllowed Can other people rate this document?
* @param string $publishDate Datetime when this document was originally published. Default is at the time of upload. See http://developers.issuu.com/managing-your-publications/date-and-time-formats/ for formatting rules
* @param string $folderIds Folders to copy the document to when processing is done. Use method Folders list to find the id of a specific folder - See http://developers.issuu.com/managing-your-publications/folders/list/
* @return object
* @return stdClass
*/
public function urlUpload(
$slurpUrl,
$name = null,
$title = null,
$tags = null,
$commentsAllowed = true,
$description = null,
$downloadable = false,
$infoLink = null,
$language = null,
$access = 'public',
$explicit = false,
$category = null,
$type = null,
$ratingAllowed = true,
$publishDate = null,
$folderIds = null
) {
string $slurpUrl,
string $name = null,
string $title = null,
string $tags = null,
bool $commentsAllowed = true,
string $description = null,
bool $downloadable = false,
string $infoLink = null,
string $language = null,
string $access = 'public',
bool $explicit = false,
string $category = null,
string $type = null,
bool $ratingAllowed = true,
string $publishDate = null,
string $folderIds = null
): stdClass {
$query = [
'action' => 'issuu.document.url_upload',
'slurpUrl' => $slurpUrl,
Expand Down Expand Up @@ -165,20 +164,20 @@ public function urlUpload(
* @param integer $pageSize Maximum number of documents to be returned. Value must be between 0 - 30. Default is 10
* @param string $documentSortBy Reponse parameter to sort the result by. Sorting can only be done on a single parameter. Default is no particular sort order
* @param string $responseParams Comma-separated list of response parameters to be returned.
* @return object
* @return stdClass
*/
public function list(
$documentStates = null,
$access = null,
$origins = null,
$orgDocTypes = null,
$orgDocName = null,
$resultOrder = 'asc',
$startIndex = 0,
$pageSize = 10,
$documentSortBy = null,
$responseParams = null
) {
string $documentStates = null,
string $access = null,
string $origins = null,
string $orgDocTypes = null,
string $orgDocName = null,
string $resultOrder = 'asc',
int $startIndex = 0,
int $pageSize = 10,
string $documentSortBy = null,
string $responseParams = null
): stdClass {
$query = [
'action' => 'issuu.documents.list',
'documentStates' => $documentStates,
Expand All @@ -193,7 +192,6 @@ public function list(
'responseParams' => $responseParams,
];

// Perform query
$documents = $this->issuu->getResponse($query);

return $documents->rsp->_content->result;
Expand All @@ -210,18 +208,18 @@ public function list(
* @param string $category 6 digit code indicating Document Category - See http://developers.issuu.com/managing-your-publications/documents/category/
* @param string $type 6 digit code indicating Document Type - See http://developers.issuu.com/managing-your-publications/documents/type/
* @param string $publishDate Datetime when this document was originally published. Default is at the time of upload. See http://developers.issuu.com/managing-your-publications/date-and-time-formats/ for formatting rules
* @return object
* @return stdClass
*/
public function update(
$name,
$title = null,
$tags = null,
$description = null,
$language = null,
$category = null,
$type = null,
$publishDate = null
) {
string $name,
string $title = null,
string $tags = null,
string $description = null,
string $language = null,
string $category = null,
string $type = null,
string $publishDate = null
): stdClass {
$query = [
'action' => 'issuu.document.update',
'name' => $name,
Expand All @@ -234,7 +232,6 @@ public function update(
'publishDate' > $publishDate,
];

// Perform query
$documents = $this->issuu->getResponse($query);

return $documents->rsp->_content;
Expand All @@ -245,14 +242,13 @@ public function update(
* @param string $names Comma-separated list of document names
* @return string
*/
public function delete($names)
public function delete(string $names): string
{
$query = [
'action' => 'issuu.document.delete',
'names' => $names,
];

// Perform query
$documents = $this->issuu->getResponse($query);

return $documents->rsp->stat;
Expand Down
31 changes: 16 additions & 15 deletions src/Folders.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<?php
declare(strict_types=1);

namespace lasselehtinen\Issuu;

use stdClass;

class Folders
{
/**
Expand All @@ -20,8 +23,9 @@ public function __construct(Issuu $issuu)
* @see https://developers.issuu.com/managing-your-publications/folders/add/
* @param string $folderName Name of the folder. Must be different from other folder names
* @param string $folderDescription Description of folder content
* @return stdClass
*/
public function add($folderName, $folderDescription = null)
public function add(string $folderName, string $folderDescription = null): stdClass
{
$query = [
'action' => 'issuu.folders.add',
Expand All @@ -40,17 +44,17 @@ public function add($folderName, $folderDescription = null)
* @param string $resultOrder "asc" or "desc"
* @param integer $startIndex Zero based index to start pagination from
* @param integer $pageSize Maximum number of documents to be returned. Value must be between 0 - 30. Default is 10
* @param string $folderSortBy Reponse parameter to sort the result by. Sorting can only be done on a single parameter. Default is no particular sort order
* @param string $folderSortBy Response parameter to sort the result by. Sorting can only be done on a single parameter. Default is no particular sort order
* @param string $responseParams Comma-separated list of response parameters to be returned.
* @return object
* @return stdClass
*/
public function list(
$resultOrder = 'asc',
$startIndex = 0,
$pageSize = 10,
$folderSortBy = null,
$responseParams = null
) {
string $resultOrder = 'asc',
int $startIndex = 0,
int $pageSize = 10,
string $folderSortBy = null,
string $responseParams = null
): stdClass {
$query = [
'action' => 'issuu.folders.list',
'resultOrder' => $resultOrder,
Expand All @@ -60,7 +64,6 @@ public function list(
'responseParams' => $responseParams,
];

// Perform query
$folders = $this->issuu->getResponse($query);

return $folders->rsp->_content->result;
Expand All @@ -72,9 +75,9 @@ public function list(
* @param string $folderId The folder to be updated
* @param string $folderName New name of the folder
* @param string $folderDescription New description of the folder
* @return object
* @return stdClass
*/
public function update($folderId, $folderName = null, $folderDescription = null)
public function update(string $folderId, string $folderName = null, string $folderDescription = null): stdClass
{
$query = [
'action' => 'issuu.folders.update',
Expand All @@ -83,7 +86,6 @@ public function update($folderId, $folderName = null, $folderDescription = null)
'folderDescription' => $folderDescription,
];

// Perform query
$folder = $this->issuu->getResponse($query);

return $folder->rsp->_content;
Expand All @@ -95,14 +97,13 @@ public function update($folderId, $folderName = null, $folderDescription = null)
* @param string $folderIds
* @return string
*/
public function delete($folderIds)
public function delete(string $folderIds): string
{
$query = [
'action' => 'issuu.folders.delete',
'folderIds' => $folderIds,
];

// Perform query
$folders = $this->issuu->getResponse($query);

return $folders->rsp->stat;
Expand Down
Loading

0 comments on commit 1741e3a

Please sign in to comment.