Function to convert array to integer values

@param   array  $array    The source array to convert
@param   mixed  $default  A default value (int|array) to assign if $array is not an array

@return  array The converted array

@since   1.0
176880
public static function toInteger($array, $default = null)
	{
		if (is_array($array))
		{
			$array = array_map('intval', $array);
		}
		else
		{
			if ($default === null)
			{
				$array = array();
			}
			elseif (is_array($default))
			{
				$array = self::toInteger($default, null);
			}
			else
			{
				$array = array((int) $default);
			}
		}

		return $array;
	}
381578
public function getArray(string $key, array $default = []): array
    {
        if (\array_key_exists($key, $this->data)) {
            if (\is_array($this->data[$key])) {
                return \array_values($this->data[$key]);
            }
            
            return (array) $this->data[$key];
        }
        
        return (array) $default;
    }
940020
protected function &getStackReference(&$array, $keys, $default = null)
    {
        $key = array_shift($keys);

        if (!isset($array[$key])) {
            return $default;
        }

        if (empty($keys)) {
            return $array[$key];
        }

        return $this->getStackReference($array[$key], $keys, $default);
    }
345569
public function getKey(array $array, string $value, $defaultValue = null)
    {
        foreach ($array as $key => $nextValue) {
            if (strcasecmp($nextValue, $value) == 0) {
                return $key;
            }
        }

        return $defaultValue;
    }
35460
public static function get($array, $key, $default = null)
    {
        $key = static::normalizeKey($key);

        if ($key === null || $key === '')
        {
            return $array;
        }

        $keys = explode('.', $key);
        $currentElement = $array;

        foreach ($keys as $currentKey)
        {
            if (!is_array($currentElement) || !array_key_exists($currentKey, $currentElement))
            {
                return $default;
            }

            $currentElement = $currentElement[(string) $currentKey];
        }

        return $currentElement;
    }
1074367
public static function first($array, $callback = null, $default = null)
    {
        if (is_null($callback)) {
            return empty($array) ? static::value($default) : reset($array);
        }

        foreach ($array as $key => $value) {
            if (call_user_func($callback, $key, $value)) {
                return $value;
            }
        }

        return static::value($default);
    }
210299
public static function first($array, $callback, $default = null)
    {
        foreach ($array as $key => $value) {
            if (call_user_func($callback, $key, $value)) {
                return $value;
            }
        }

        return $default;
    }
51810
public static function first( $array, $callback, $default = NULL )
    {
        foreach ( $array as $key => $value )
        {
            if ( call_user_func( $callback, $key, $value ) ) return $value;
        }

        return Util::value( $default );
    }
171384
public static function get(array $array, $key = null, $default = null)
    {
        if (is_null($key)) {
            return;
        }

        if (isset($array[$key])) {
            return $array[$key];
        }

        foreach (explode('.', $key) as $token) {
            if (! is_array($array) or ! array_key_exists($token, $array)) {
                return $default;
            }

            $array = $array[$token];
        }

        return $array;
    }
1054452
public static function pull(&$array, $key, $default = null)
    {
        if (array_key_exists($key, $array)) {
            $value = $array[$key];
            unset($array[$key]);
        } else {
            $value = $default;
        }

        return $value;
    }
1297806
public static function get(array $array, $key, $default = null)
    {
        if (array_key_exists($key, $array)) {
            return $array[$key];
        }

        if (strpos($key, '.') === false) {
            return $default;
        }

        foreach (explode('.', $key) as $segment) {
            if (is_array($array) && array_key_exists($segment, $array)) {
                $array = $array[$segment];
            } else {
                return $default;
            }
        }

        return $array;
    }
934334
public function getArrayLevel($array)
	{
		$n=1;
		foreach ($array as $item) {
			if(is_array($item)){
				$n=$this->getArrayLevel($item)+1;
			}
		}
		return $n;

	}
595162
public static function defaultValues(array $values, array &$array)
    {
        foreach ($values as $name => $value) {
            self::defaultValue($name, $value, $array);
        }
    }
9303
public static function buildFromArray($array)
    {
        $returnValue = null;

        
        if (!empty($array)){
        	if (!empty($array['type'])){
        		$acceptedTypes = array('PHPRuntime', 'PHPINIValue', 'PHPExtension', 'PHPDatabaseDriver', 'FileSystemComponent', 'Custom', 'Mock');
        		$cleanType = preg_replace('/^Check/i', '', $array['type']);
        		if (in_array($cleanType, $acceptedTypes)){
        			
        			if (!empty($array['value'])){
        				$values = $array['value'];
        				
        				// Optional parameter is always used.
        				$optional = false;
        				if (!empty($values['optional'])){
        					$optional = $values['optional'];
        				}
        				
	        			switch ($cleanType){
	        				case 'PHPRuntime':
	        					$max = null;
	        					if (!empty($values['max'])){
	        						$max = $values['max'];
	        					}
	        					
	        					if (empty($values['min'])){
	        						$msg = "Mandatory attribute 'min' is missing.";
	        						throw new common_configuration_ComponentFactoryException($msg);	
	        					}
	        					
	        					$returnValue = self::buildPHPRuntime($values['min'], $max, $optional);
	        				break;
	        				
	        				case 'PHPINIValue':
	        					if (empty($values['name'])){
	        						$msg = "Mandatory attribute 'name' is missing.";
	        						throw new common_configuration_ComponentFactoryException($msg);	
	        					}
	        					
	        					if (empty($values['value']) && $values['value'] !== '0'){
	        						$msg = "Mandatory attribute 'value' is missing.";
	        						throw new common_configuration_ComponentFactoryException($msg);	
	        					}
	        					
	        					$returnValue = self::buildPHPINIValue($values['name'], $values['value'], $optional);
	        				break;
	        				
	        				case 'PHPExtension':
	        					if (empty($values['name'])){
	        						$msg = "Mandatory attribute 'name' is missing.";
	        						throw new common_configuration_ComponentFactoryException($msg);	
	        					}
	        					
	        					$min = null;
	        					if (!empty($values['min'])){
	        						$min = $values['min'];	
	        					}
	        					
	        					$max = null;
	        					if (!empty($values['max'])){
	        						$max = $values['max'];	
	        					}
	        					
	        					$returnValue = self::buildPHPExtension($values['name'], $min, $max, $optional);
	        				break;
	        				
	        				case 'PHPDatabaseDriver':
	        					if (empty($values['name'])){
	        						$msg = "Mandatory attribute 'name' is missing.";
	        						throw new common_configuration_ComponentFactoryException($msg);	
	        					}
	        					
	        					$returnValue = self::buildPHPDatabaseDriver($values['name'], $optional);
	        				break;
	        				
	        				case 'FileSystemComponent':
	        					if (empty($values['location'])){
	        						$msg = "Mandatory attribute 'location' is missing.";
	        						throw new common_configuration_ComponentFactoryException($msg);	
	        					}
	        					
	        					if (empty($values['rights'])){
	        						$msg = "Mandatory attribute 'rights' is missing.";
	        						throw new common_configuration_ComponentFactoryException($msg);	
	        					}
	        					
	        					$returnValue = self::buildFileSystemComponent($values['location'], $values['rights'], $optional);
	        				break;
	        				
	        				case 'Custom':
	        					if (empty($values['name'])){
	        						$msg = "Mandatory attribute 'name' is missing.";
	        						throw new common_configuration_ComponentFactoryException($msg);	
	        					}

	        					$extension = 'generis';
	        					if (!empty($values['extension'])){
	        						$extension = $values['extension'];
	        					}
	        					
	        					$returnValue = self::buildCustom($values['name'], $extension, $optional);
	        				break;
	        				
	        				case 'Mock':
	        					$status = common_configuration_Report::VALID; 
	        					if (!empty($values['status'])){
	        						$status = $values['status'];
	        					}
	        					
	        					$returnValue = self::buildMock($status, $optional);
	        				break;
	        			}	
        			}
        			else{
        				$msg = "No 'value' array provided.";
        				throw new common_configuration_ComponentFactoryException($msg);
        			}
        		}
        		else{
        			$msg = "Unknown 'type' = '${cleanType}'.";
        			throw new common_configuration_ComponentFactoryException($msg);
        		}
        	}
        	else{
        		$msg = "Cannot build a Configuration Component without 'type'.";
        		throw new common_configuration_ComponentFactoryException($msg);
        	}
        }
        else{
        	$msg = 'Cannot build a Configuration Component with an empty array.';
        	throw new common_configuration_ComponentFactoryException($msg);
        }
        

        return $returnValue;
    }
851762
public static function normalize(array $array, $default): array
    {
        $normalized = [];

        foreach ($array as $key => $value) {
            if (is_numeric($key)) {
                $key = $value;
                $value = $default;
            }

            $normalized[$key] = $value;
        }

        return $normalized;
    }
632177
public static function get( $array, $key, $default = NULL )
    {
        if ( is_null( $key ) ) return $array;

        if ( isset( $array[ $key ] ) ) return $array[ $key ];

        foreach ( explode( '.', $key ) as $segment )
        {
            if ( !is_array( $array ) || !array_key_exists( $segment, $array ) )
            {
                return Util::value( $default );
            }

            $array = $array[ $segment ];
        }

        return $array;
    }
52547
public static function getArrayBaseValue($index, $default = [])
    {
        $values = (array) self::getCustom($index, []);

        return array_merge((array) self::get($index, $default), $values);
    }