<?php

namespace App\Helpers\Part;

use App\Helpers\CommonHelper;
use RuntimeException;

abstract class PartHelper extends CommonHelper
{
  protected function __construct()
  {
    parent::__construct();
  }

  public function getFieldView(string $field, mixed $value, array $viewDatas, array $extras = []): string|null
  {
    switch ($field) {
      case 'price':
        $value = number_format($value) . "원";
        break;
      default:
        $value = parent::getFieldView($field, $value, $viewDatas, $extras);
        break;
    }
    if (is_array($value)) {
      throw new RuntimeException(static::class . "->" . __FUNCTION__ . "에서 오류발생:{$field}에 해당하는 Return 값이 배열형식입니다.\n" . var_export($value, true));
    }
    return $value;
  }
}
