Write a function that converts an integer into a roman numeral.
- Throw an exception if input is invalid (e.g. 0 or negative)
Create a String calculator class with a function: add(string $string) : int
This method takes a string of numbers (each number is separated by a comma. It returns the sum of all the numbers. Empty string is treated as a 0.
For example:
""
returns0
"2"
returns2
"4,9"
returns13
"1,2,3"
returns6
- Don't forget to code for invalid input data.
- Update add function to take delimiter:
add(string $string, string $delimiter) : int
- Ignore negative numbers. E.g.
"4,-9,6"
returns10
Write a password strength validator. There is a method: isValid(string $password) : bool
The method returns true if the password is valid. A password is valid if:
- at least 5 characters long
- contains 1 lower case letter
- contains 1 upper case letter
- contains 1 digit
Write an implementation for a template parser: parseTemplate(string $template, array $substitutions) : string
A template might look like this "Hello {name}. Today is turn {age}. Happy Birthday!"
The substitutions array might look like this: ['name' => 'Bob', 'age' => 21]
- Throw exception if the is no value for the place holder.
- Allow default values. e.g.
{age|21}
, when no age is present the text after the | is used, in this case21
. - Allow the substitution values to contain curly braces.