<?php
namespace nur\data\types;

use nur\str;
use nur\txt;

/**
 * Class TextType: un texte encodé en utf-8
 */
class TextType extends StringType {
  function beforeCheckInstance(&$value): bool {
    if (is_array($value)) $value = str::join3($value);
    if ($this->ppChangeCase !== null && is_string($value)) {
      switch ($this->ppChangeCase) {
      case "upper":
      case "uc":
        $value = txt::upper($value);
        break;
      case "upper1":
      case "u1":
        $value = txt::upper1($value);
        break;
      case "upperw":
      case "uw":
        $value = txt::upperw($value);
        break;
      case "lower":
      case "lc":
        $value = txt::lower($value);
        break;
      case "lower1":
      case "l1":
        $value = txt::lower1($value);
        break;
      }
    }
    return true;
  }
}
