<?php

namespace Types;

class Integer {
  
  

  
  

    // --- Statische Methoden ---
  
  public static function decimalSeparator() { 
    
    
    // --- BLOCK: main ---
    return _('.');
    
  }

  public static function thousandsSeparator() { 
    
    
    // --- BLOCK: main ---
    return '';
    
  }

  public static function pattern() { 
    
    
    // --- BLOCK: main ---
    
		$escape = function ($x) { return $x == '.' ? '\.' : $x; };
		return '-?[0-9' . self::thousandsSeparator() . ']+(?:' . self::decimalSeparator() . '\d+)?';
    
  }

  public static function parse($x) { 
    
    
    // --- BLOCK: main ---
    
		$x = str_replace(self::thousandsSeparator(), '', $x);
		$x = str_replace(self::decimalSeparator(), '.', $x);
		$x = preg_replace('/[^0-9\-\.]/', '', $x);
		return json_decode($x);
	
    
  }

  public static function unpack($x) { 
    
    
    // --- BLOCK: main ---
    
		if ($x === null) return null;
		if (is_int($x)) return $x;
		return intval(json_decode($x));
	
    
  }

  public static function print($x) { 
    
    
    // --- BLOCK: main ---
    
		
		$x = number_format($x, 0, self::decimalSeparator(), self::thousandsSeparator());
		
		return $x;
	
    
  }


  
  

  
  
}



