@@ 307-321 (lines=15) @@ | ||
304 | * |
|
305 | * @return string |
|
306 | */ |
|
307 | public static function LEFT($value = '', $chars = 1) |
|
308 | { |
|
309 | $value = Functions::flattenSingleValue($value); |
|
310 | $chars = Functions::flattenSingleValue($chars); |
|
311 | ||
312 | if ($chars < 0) { |
|
313 | return Functions::VALUE(); |
|
314 | } |
|
315 | ||
316 | if (is_bool($value)) { |
|
317 | $value = ($value) ? \PhpOffice\PhpSpreadsheet\Calculation::getTRUE() : \PhpOffice\PhpSpreadsheet\Calculation::getFALSE(); |
|
318 | } |
|
319 | ||
320 | return mb_substr($value, 0, $chars, 'UTF-8'); |
|
321 | } |
|
322 | ||
323 | /** |
|
324 | * MID. |
|
@@ 361-375 (lines=15) @@ | ||
358 | * |
|
359 | * @return string |
|
360 | */ |
|
361 | public static function RIGHT($value = '', $chars = 1) |
|
362 | { |
|
363 | $value = Functions::flattenSingleValue($value); |
|
364 | $chars = Functions::flattenSingleValue($chars); |
|
365 | ||
366 | if ($chars < 0) { |
|
367 | return Functions::VALUE(); |
|
368 | } |
|
369 | ||
370 | if (is_bool($value)) { |
|
371 | $value = ($value) ? \PhpOffice\PhpSpreadsheet\Calculation::getTRUE() : \PhpOffice\PhpSpreadsheet\Calculation::getFALSE(); |
|
372 | } |
|
373 | ||
374 | return mb_substr($value, mb_strlen($value, 'UTF-8') - $chars, $chars, 'UTF-8'); |
|
375 | } |
|
376 | ||
377 | /** |
|
378 | * STRINGLENGTH. |