https://kata-log.rocks/string-calculator-kata
To execute the project, build a custom Docker image with PHP 8.2 and xDebug enabled.
FROM php:8.2-cli
# Install Xdebug
RUN pecl install xdebug \
&& docker-php-ext-enable xdebug
After running the commands:
$ make test
$ make coverage
- Step 1
- "" = 0
- "1" = 1
- "1,2" = 3
- Step 2
- "3,5,1" = 9
- Step 3
- "1\n2,3" = 6
- Step 4
- "//;\n1;2" = 3 (format "//[delimiter]\n[numbers…]")
- Step 5
- "-1" = exception "Negatives not allowed: -1"
- Step 6
- "2 + 1001" = 2 (Numbers bigger than 1000 should be ignored)
- Step 7
- "//[]\n12***3" = 6 (format "//[delimiter]\n")
- Step 8
- "//[][%]\n12%3" = 6 (format //[delim1][delim2]\n)
- Step 9
- "//[][%%]\n33%%3" = 9 (handle multiple delimiters with length longer than one char)