@param      $value
@param bool $asInt
@param bool $nullable

@return string|int|null
541165
public static function digits($value, $asInt = FALSE, $nullable = TRUE)
	{
		$value = preg_replace('/\D+/', '', (string) $value);
		if ($nullable && !strlen($value)) $value = NULL;

		return $asInt ? self::setTypeInt($value, $nullable) : $value;
	}
1033139
public function getMonth($asInt = true)
    {
        $value = fmod($this->getRyzomMonth(), self::RYZOM_CYCLE_IN_MONTH) + 1;

        return $asInt ? (int) $value : $value;
    }
836958
public function value($value, $type = null)
    {
        switch (true) {
            case is_object($value):
                if (!method_exists($value, '__toString')) {
                    throw new InvalidArgumentException('Object can not be converted to string value.');
                }
                $value = (string)$value;
                break;
            case is_bool($value):
                $value = (int)$value;
                break;
            case (is_numeric($value) && (string)($value + 0) === (string)$value):
                $value = $value + 0;
                break;
            case is_null($value):
                $value = 'NULL';
                break;
            case is_array($value):
                $value = array_map(function ($value) {
                    if (is_array($value)) {
                        $value = 'Array';
                    }
                    return $this->value($value);
                }, $value);
                $value = implode(', ', $value);
                break;
            default:
                $value = call_user_func($this->quoteFn, $value, $type);
        }

        return $value;
    }
1141967
public function extract($value)
    {
        if ($this->nullable && $value === null) {
            return null;
        }

        $return = [];
        if (is_array($value) || $value instanceof \Traversable) {
            foreach ($value as $key => $object) {
                $return[$key] = $this->hasOneStrategy->extract($object);
            }
        } else {
            throw new Exception\InvalidArgumentException(sprintf(
                'Value must be null (only if nullable option is enabled), or an array, or a Traversable: "%s" given',
                is_object($value) ? get_class($value) : gettype($value)
            ));
        }

        return $return;
    }
27905
public function transform($value)
    {
        if (null === $value) {
            return null;
        }

        if (!is_bool($value)) {
            throw new TransformationFailedException('Expected a boolean.');
        }

        return $value ? $this->trueValue : $this->falseValue;
    }
163524
public static function getValueWithinItsType($value, $knownType = null)
    {
        if (is_int($value) || (!is_null($value) && in_array($knownType, array(
            'time',
            'positiveInteger',
            'unsignedLong',
            'unsignedInt',
            'short',
            'long',
            'int',
            'integer',
        ), true))) {
            return intval($value);
        } elseif (is_float($value) || (!is_null($value) && in_array($knownType, array(
            'float',
            'double',
            'decimal',
        ), true))) {
            return floatval($value);
        } elseif (is_bool($value) || (!is_null($value) && in_array($knownType, array(
            'bool',
            'boolean',
        ), true))) {
            return ($value === 'true' || $value === true || $value === 1 || $value === '1');
        }
        return $value;
    }
1248546
static function findKey($value): ?string
    {
        return self::hasValue($value)
            ? self::$valueToKeyMap[static::class][$value]
            : null;
    }
262660
private static Number asNumber(Object value) {
    Number num = null;
    if (value == null) {
      num = null;
    } else if (value instanceof Number) {
      num = (Number) value;
    } else if (value instanceof Boolean) {
      num = ((Boolean) value) ? 1 : 0;
    }
    return num;
  }
125949
public static function getTypeCodeFromObject( $value )
	{
		if ( is_null( $value ) )
		{
			return TypeCode::Null_;
		}

		if ( is_array( $value ) )
		{
			return TypeCode::assocArray;
		}

		if ( is_string( $value ) )
		{
			return strlen( $value ) === 1 ? TypeCode::Char : TypeCode::String;
		}

		if ( $value instanceof DateTime )
		{
			return TypeCode::DateTime;
		}

		if ( $value instanceof DateTimeInterval )
		{
			return TypeCode::DateTimeInterval;
		}

		if ( is_double( $value ) )
		{
			return TypeCode::Double;
		}

		if ( is_int( $value ) )
		{
			return TypeCode::Int32;
		}

		if ( is_bool( $value ) )
		{
			return TypeCode::Boolean;
		}

		if ( is_object( $value ) )
		{
			return TypeCode::Object;
		}
	}
695180
@Nullable
    public static String nullIfBlank(@Nullable String value) {
        if (isBlank(value)) {
            return null;
        }
        return value;
    }
456976
public function convertToDatabaseValue($value, AbstractPlatform $platform)
    {
        if (empty($value)) {
            return null;
        }

        if ($value instanceof UuidInterface) {
            return $value->getBytes();
        }

        try {
            if (is_string($value) || method_exists($value, '__toString')) {
                return Uuid::fromString((string) $value)->getBytes();
            }
        } catch (InvalidArgumentException $e) {
            // Ignore the exception and pass through.
        }

        throw ConversionException::conversionFailed($value, static::NAME);
    }
1111793
private function getTransferEnvValue($value, bool $isArray)
    {
        if ($value === null) {
            return null;
        }

        if ($isArray == false) {
            return $value;
        }

        if (empty($value)) {
            $value = [];
        } else {
            $value = explode(",", $value);
        }

        return $value;
    }
708105
protected function instance(&$value)
    {
        foreach ($this->instances as &$tuple) {
            if ($tuple[0] === $value) {
                if (
                    is_array($value) &&
                    !$this->isArrayReference($tuple[0], $value)
                ) {
                    continue;
                }

                return $tuple[1];
            }
        }

        return null;
    }
676055
protected function castToString($value, bool $nullable = true)
    {
        if (null === $value && $nullable) {
            return null;
        }

        return (string) $value;
    }
920505
protected function _value($value)
    {
        if ($value === null) {
            return 'null';
        }
        if ($value === true) {
            return 'true';
        }
        if ($value === false) {
            return 'false';
        }

        return (string)$value;
    }
88742
public function isAssignableFromValue($value)
    {
        switch ($this->name)
        {
            case self::INTEGER_NAME:
                return is_int($value);
            case self::FLOAT_NAME:
                return is_float($value);
            case self::STRING_NAME:
                return is_string($value);
            case self::BOOLEAN_NAME:
                return is_bool($value);
            case self::MIXED_NAME:
                return true;
            case self::RESOURCE_NAME:
                return is_resource($value);
            case self::OBJECT_NAME:
                return is_object($value);
            case self::NULL_NAME:
                return is_null($value);
            case self::CALLABLE_NAME:
                return is_callable($value);
            default:
                throw new Exception("Implementation error");
        }
    }
1294952
static List<String> integer(String name, @Nullable Integer value) {
    if (value != null) {
      return Arrays.asList("--" + name, value.toString());
    }
    return Collections.emptyList();
  }