Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Yes, I know that, I was just wondering whether it's worth fixing it in one PHP version only.
Funny enough, now that I tested around with a changed version of the random test, I noticed it did not actually work anyway, at all.
The test method providing the real solution was called without
$this
, and named the same as the real solution (except character case) - which seemed to have called the real solution twice, for$expected
and$actual
, making the test effectively useless.While I would technically agree with that, and potentially drop that echo completely without replacement, this has not been added in this PHP8 upgrade translation. If it were to be dropped/replaced, I guess it should be dropped in all versions?
Translated to PHP
Go translation
If you surround your code with three backticks (```), it will put it in a codeblock, which is far easier readable.
See: https://docs.codewars.com/references/markdown#displaying-code
Added.
Also added a specific test case to clarify that uppercase letters not at the beginning of a word would stay uppercase.
Added PHP 8.0 support
This also fixes a bug in the solution (see comment on the fork)
Added PHP 8.0 support
Also, fixed a bug in the solution which only got visible since PHP 8.0, due to slight changes in string to number conversion:
It checked against the wrong element of the matches array, the element at offset 0 is the whole matched string, not the first capture group. So, both checks were using elements off by one.
A small additional simplification, since the regex only captures the number itself, without the optional
-
, there is no need to check for negative threshold.Added PHP 8.0 support
Added PHP 8.0 support
Added PHP 8.0 support
Added PHP 8.0 support
Added PHP 8.0 support
Added PHP 8.0 support
$expected
and$actual
order (see PHPUnit docs)Added PHP 8.0 support
Loading more items...