Пример #1
0
 /**
  * @param string $text
  * @param int $requiredLength
  * @param bool $addDots [optional]
  * @return string
  */
 public function chop($text, $requiredLength, $addDots = true)
 {
     df_param_string($text, 0);
     df_param_integer($requiredLength, 1);
     df_param_between($requiredLength, 1, 0);
     df_param_boolean($addDots, 2);
     return mb_strlen($text) <= $requiredLength ? $text : df_ccc('', $this->trim(mb_substr($text, 0, $requiredLength - ($addDots ? 3 : 0))), $addDots ? '...' : null);
 }
Пример #2
0
 /**
  * @param int $number
  * @param string $gender
  * @return string
  */
 private function getNaturalNumberInWords($number, $gender)
 {
     df_param_integer($number, 0);
     df_param_between($number, 0, 0, self::MAX_NUMBER);
     df_param_string($gender, 1);
     df_assert_in($gender, [self::GENDER__MALE, self::GENDER__FEMALE]);
     /** @var string $result */
     $result = 'ноль';
     if (0 !== $number) {
         $result = preg_replace(['/s+/', '/\\s$/'], [' ', ''], $this->getNum1E9($number, $gender));
     }
     df_result_string($result);
     return $result;
 }