Skip to content

Commit

Permalink
– added an error message for the CalculatorAbstract class
Browse files Browse the repository at this point in the history
– fixed the error message method's name for the TimeUtils class
  • Loading branch information
uruba committed Feb 15, 2016
1 parent 7af4da8 commit e563f66
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
26 changes: 23 additions & 3 deletions src/Constants/ErrorMessages.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,17 +133,37 @@ static function getInvalidTypeMessage() {
}

/**
* @return string [message as a string]
* @return string [Message as a string]
*/
static function getStartDateMustBeBeforeEndDateMessage() {
return Strings::getString('message_start_date_must_be_before_end_date');
}

/**
* @return string [message as a string]
* @return string [Message as a string]
*/
static function getDayCountConventionNotDefined() {
static function getDayCountConventionNotDefinedMessage() {
return Strings::getString('message_day_count_convention_not_defined');
}

/**
* @return string [Message as a string]
*/
static function getPropresultarrayNotSuppliedMessage() {
return Strings::getString('message_propresultarray_not_supplied');
}

/**
* @param $methodName [Name of the method]
* @param $className [Name of the class]
* @return string [Concatenated message as a string]
*/
static function getMethodDoesNotExistMessage($methodName, $className) {
return Strings::getFormattedString(
'message_method_does_not_exist',
$methodName,
$className
);
}
}
}
4 changes: 2 additions & 2 deletions src/Interfaces/Calculator/CalculatorAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public final function getResultAsArray(array $propResultArray = null) {
if ($this->propResultArray !== null && is_array($this->propResultArray)) {
$propResultArray = $this->propResultArray;
} else {
error_log('$propResultArray has not been supplied neither by the argument, nor by the class field');
error_log(ErrorMessages::getPropresultarrayNotSuppliedMessage());
return false;
}
}
Expand All @@ -58,7 +58,7 @@ public final function getResultAsArray(array $propResultArray = null) {
if (method_exists($this, $propGetter)) {
$processedArray[is_string($key) ? $key : $prop] = call_user_func(array($this, $propGetter));
} else {
error_log("Method '" . $propGetter . "()' doesn't exist in the class " . get_class($this));
error_log(ErrorMessages::getMethodDoesNotExistMessage($propGetter, get_class($this)));
}
}
if (is_array($prop)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Utils/Time/TimeUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public static function getCurrentDayCountConvention() {
return $dayCountConvention;
}

throw new Exception(ErrorMessages::getDayCountConventionNotDefined());
throw new Exception(ErrorMessages::getDayCountConventionNotDefinedMessage());
}

/**
Expand Down
4 changes: 3 additions & 1 deletion src/locale/en.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@
'message_class_not_defined' => 'Class %s not defined',
'message_invalid_type_specified' => 'Invalid type specified!',
'message_start_date_must_be_before_end_date' => 'Start date has to be lower than the end date!',
'message_day_count_convention_not_defined' => 'The day count convention is not defined properly in the config!'
'message_day_count_convention_not_defined' => 'The day count convention is not defined properly in the config!',
'message_propresultarray_not_supplied' => '$propResultArray has not been supplied neither by the argument, nor by the class field',
'message_method_does_not_exist' => 'Method %s doesn\'t exist in the class %s!'
);

0 comments on commit e563f66

Please sign in to comment.