code: static function isValid($unit, $throw = false)
      {
          if (in_array($unit, static::getUnits(), true)) {
              return true;
          }
  
          if ($throw) {
              throw new InvalidArgumentException("Invalid unit '$unit'.");
          }
  
          return false;
      }
docs: Returns whether the given unit is valid.
  
  @param string $unit
  @param bool   $throw
  
  @return bool