Skip to content

Commit

Permalink
remove unused vars
Browse files Browse the repository at this point in the history
  • Loading branch information
maztch committed Apr 18, 2017
1 parent f09fb83 commit ec9f5fa
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 31 deletions.
3 changes: 0 additions & 3 deletions samples/merge_advanced.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
$fileA = $myTask->addFile('/path/to/file/document_a.pdf');
$fileB = $myTask->addFile('/path/to/file/document_b.pdf');

// set compression level
$myTask->setCompressionLevel('extreme');

// and set name for output file.
// the task will set the correct file extension for you.
$myTask->setOutputFilename('merged_filename');
Expand Down
2 changes: 1 addition & 1 deletion samples/watermark_advanced.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
$myTask->setVerticalPosition("top");

// set horizontal position
$myTask->setHorizontalPosition("rigth");
$myTask->setHorizontalPosition("right");

// adjust vertical position
$myTask->setVerticalPositionAdjustment("100");
Expand Down
5 changes: 1 addition & 4 deletions src/Ilovepdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ class Ilovepdf
// @var string|null The version of the Ilovepdf API to use for requests.
public static $apiVersion = 'v1';

// @var string|null Disable Exceptions if needed.
public static $exceptions = true;

const VERSION = 'php.1.0.5';
const VERSION = 'php.1.0.10';

public $token = null;

Expand Down
86 changes: 63 additions & 23 deletions src/Task.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,7 @@ class Task extends Ilovepdf
public $output_filename;
public $ignore_errors = true;
public $ignore_password = true;

const STATUS_WAITING = 'TaskWaiting';
const STATUS_PROCESSING = 'TaskProcessing';
const STATUS_SUCCESS = 'TaskSuccess';
const STATUS_SUCCESSWITHWARNINGS = 'TaskSuccessWithWarnings';
const STATUS_ERROR = 'TaskError';
const STATUS_DELETED = 'TaskDeleted';
const STATUS_NOTFOUND = 'TaskNotFound';
public $try_pdf_repair = true;

/**
* Task constructor.
Expand Down Expand Up @@ -151,10 +144,10 @@ public function uploadUrl($task, $url)
* @param null|string $path
* @param null|string $file
*/
public function download($path = null, $file = null)
public function download($path = null)
{
//$download = new Download();
$this->downloadFile($this->task, $path, $file);
$this->downloadFile($this->task, $path);
return;
}

Expand Down Expand Up @@ -241,7 +234,56 @@ public function setOutputFilename($filename)
$this->output_filename = $filename;
}

public function deleteFile($file){
if (($key = array_search($file, $this->files)) !== false) {
$body = Request\Body::multipart(['task'=>$this->getTaskId(), 'server_filename'=>$file->server_filename, 'v'=> self::VERSION]);
$this->sendRequest('post', 'upload/delete', $body);
unset($this->files[$key]);
}
}

/**
* @param mixed $value
* @param array $allowed
*/
public function checkValues($value, $allowedValues){
if(!in_array($value, $allowedValues)){
throw new \InvalidArgumentException('Invalid '.$this->tool.' value "'.$value.'". Must be one of: '.implode(',', $allowedValues));
}
}

/**
* @param boolean $try_pdf_repair
*/
public function setTryPdfRepair($try_pdf_repair)
{
$this->try_pdf_repair = $try_pdf_repair;
}

/**
* @param boolean $ignore_errors
*/
public function setIgnoreErrors($ignore_errors)
{
$this->ignore_errors = $ignore_errors;
}

/**
*
*
* @param boolean $ignore_password
*/
public function setIgnorePassword($ignore_password)
{
$this->ignore_password = $ignore_password;
}


/**
* alias for setIgnoreError
*
* Will be deprecated on v2.0
*
* @param boolean $value If true, and multiple archives are processed it will ignore files with errors and continue process for all others
*/
public function ignoreErrors($value)
Expand All @@ -250,28 +292,26 @@ public function ignoreErrors($value)
}

/**
* alias for setIgnorePassword
*
* Will be deprecated on v2.0
*
* @param boolean $value
*/
public function ignorePassword($value)
{
$this->ignore_password = $value;
}

public function deleteFile($file){
if (($key = array_search($file, $this->files)) !== false) {
$body = Request\Body::multipart(['task'=>$this->getTaskId(), 'server_filename'=>$file->server_filename, 'v'=> self::VERSION]);
$this->sendRequest('post', 'upload/delete', $body);
unset($this->files[$key]);
}
}

/**
* @param mixed $value
* @param array $allowed
* @param boolean $value
*/
public function checkValues($value, $allowedValues){
if(!in_array($value, $allowedValues)){
throw new \InvalidArgumentException('Invalid compress level value "'.$value.'". Must be one of: '.implode(',', $allowedValues));
public function setFileEncryption($value, $encryptKey=null)
{
if(count($this->files)>0){
throw new \Exception('Encrypth mode cannot be set after file upload');
}

parent::setFileEncryption($value, $encryptKey);
}
}

0 comments on commit ec9f5fa

Please sign in to comment.