Skip to content

Commit e563f66

Browse files
committed
– added an error message for the CalculatorAbstract class
– fixed the error message method's name for the TimeUtils class
1 parent 7af4da8 commit e563f66

File tree

4 files changed

+29
-7
lines changed

4 files changed

+29
-7
lines changed

src/Constants/ErrorMessages.php

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,17 +133,37 @@ static function getInvalidTypeMessage() {
133133
}
134134

135135
/**
136-
* @return string [message as a string]
136+
* @return string [Message as a string]
137137
*/
138138
static function getStartDateMustBeBeforeEndDateMessage() {
139139
return Strings::getString('message_start_date_must_be_before_end_date');
140140
}
141141

142142
/**
143-
* @return string [message as a string]
143+
* @return string [Message as a string]
144144
*/
145-
static function getDayCountConventionNotDefined() {
145+
static function getDayCountConventionNotDefinedMessage() {
146146
return Strings::getString('message_day_count_convention_not_defined');
147147
}
148+
149+
/**
150+
* @return string [Message as a string]
151+
*/
152+
static function getPropresultarrayNotSuppliedMessage() {
153+
return Strings::getString('message_propresultarray_not_supplied');
154+
}
155+
156+
/**
157+
* @param $methodName [Name of the method]
158+
* @param $className [Name of the class]
159+
* @return string [Concatenated message as a string]
160+
*/
161+
static function getMethodDoesNotExistMessage($methodName, $className) {
162+
return Strings::getFormattedString(
163+
'message_method_does_not_exist',
164+
$methodName,
165+
$className
166+
);
167+
}
148168
}
149169
}

src/Interfaces/Calculator/CalculatorAbstract.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public final function getResultAsArray(array $propResultArray = null) {
4545
if ($this->propResultArray !== null && is_array($this->propResultArray)) {
4646
$propResultArray = $this->propResultArray;
4747
} else {
48-
error_log('$propResultArray has not been supplied neither by the argument, nor by the class field');
48+
error_log(ErrorMessages::getPropresultarrayNotSuppliedMessage());
4949
return false;
5050
}
5151
}
@@ -58,7 +58,7 @@ public final function getResultAsArray(array $propResultArray = null) {
5858
if (method_exists($this, $propGetter)) {
5959
$processedArray[is_string($key) ? $key : $prop] = call_user_func(array($this, $propGetter));
6060
} else {
61-
error_log("Method '" . $propGetter . "()' doesn't exist in the class " . get_class($this));
61+
error_log(ErrorMessages::getMethodDoesNotExistMessage($propGetter, get_class($this)));
6262
}
6363
}
6464
if (is_array($prop)) {

src/Utils/Time/TimeUtils.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public static function getCurrentDayCountConvention() {
131131
return $dayCountConvention;
132132
}
133133

134-
throw new Exception(ErrorMessages::getDayCountConventionNotDefined());
134+
throw new Exception(ErrorMessages::getDayCountConventionNotDefinedMessage());
135135
}
136136

137137
/**

src/locale/en.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,7 @@
1616
'message_class_not_defined' => 'Class %s not defined',
1717
'message_invalid_type_specified' => 'Invalid type specified!',
1818
'message_start_date_must_be_before_end_date' => 'Start date has to be lower than the end date!',
19-
'message_day_count_convention_not_defined' => 'The day count convention is not defined properly in the config!'
19+
'message_day_count_convention_not_defined' => 'The day count convention is not defined properly in the config!',
20+
'message_propresultarray_not_supplied' => '$propResultArray has not been supplied neither by the argument, nor by the class field',
21+
'message_method_does_not_exist' => 'Method %s doesn\'t exist in the class %s!'
2022
);

0 commit comments

Comments
 (0)