Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Test
- {
- /**
- *
- */
- public function getName($num = 0)
- {
- $num = (int)$num;
- if ($num >= 0 && $num <= 99) {
- return $this->get($num);
- } else {
- return $this->get((int)substr((string)$num, (strlen((string)$num) - 2), 2));
- }
- }
- /**
- *
- */
- private function get($num = 0)
- {
- if ($num >=11 && $num <= 19) {
- return 'Дней';
- } else {
- $num = (int)($num < 10 ? $num : substr((string)$num, 1, 1));
- switch (true) {
- case $num == 1:
- return 'День';
- case $num >=2 && $num <=4:
- return 'Дня';
- default:
- return 'Дней';
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement