Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add getter and setter for error messages #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions Zebra_Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,14 @@ class Zebra_Image
* @var string
*/
public $target_path;

/**
* Array for error messages
*
* @var array
*/
public $error_messages = array();


/**
* Constructor of the class.
Expand All @@ -210,6 +218,19 @@ function __construct()
$this->sharpen_images = false;

$this->source_path = $this->target_path = '';

/**
* Array with default error messages
*/
$this->error_messages = array(
'Source file could not be found!',
'Source file is not readable!',
'Could not write target file!',
'Unsupported source file format!',
'Unsupported target file format!',
'GD library version does not support target file format!',
'GD library is not installed!'
);

}

Expand Down Expand Up @@ -1703,5 +1724,26 @@ private function _write_image($identifier)
return true;

}

/**
* Return the error message
*
* @return mixed
*/
public function getErrorMessage(){
return $this->error_messages[$this->error];
}

/**
* Set custom error messages
*
* @param array $error_messages
*/
public function setErrorMessages($error_messages = array())
{
$this->error_messages = $error_messages;
}

}

}