Determine whether an array value is empty, taking into account casting.

@param  string  $key
@param  array  $value

@return mixed
747
private function nullIfEmptyArray($key, $value)
    {
        if ($this->isJsonCastable($key) && ! empty($value)) {
            return $this->setJsonCastValue($value);
        }

        return empty($value) ? null : $value;
    }
1275520
protected function castArrayValue($value)
    {
        if (!is_object($value)) {
            return $this->key($value);
        }

        try {
            if ($key = $this->objectCategorizer->key($value)) {
                return $this->hashIfToLong($key);
            }
        } catch (Exception $e) {
        }

        return $this->hashIfToLong($this->objectToKey($value));
    }
697000
protected function castAttribute($key, $value)
	{
		if (is_null($value)) return $value;

		switch ($this->getCastType($key))
		{
			case 'int':
			case 'integer':
				return (int) $value;
			case 'real':
			case 'float':
			case 'double':
				return (float) $value;
			case 'string':
				return (string) $value;
			case 'bool':
			case 'boolean':
				return (bool) $value;
			case 'object':
				return json_decode($value);
			case 'array':
			case 'json':
				return json_decode($value, true);
			case 'collection':
				return $this->newCollection(json_decode($value, true));
			default:
				return $value;
		}
	}
171612
public static function array_set(string $key, $value, array $obj)
    {
        if (is_null($key)) {
            return json_encode($obj);
        }
        $keys = explode('.', $key);
        $tmp = &$obj;
        while (count($keys) > 0) {
            $key = array_shift($keys);

            // If the key doesn't exist at this depth, we will just create an empty array
            // to hold the next value, allowing us to create the arrays to hold final
            // values at the correct depth. Then we'll keep digging into the array.
            if (!isset($tmp[$key]) || !is_array($tmp[$key])) {
                $tmp[$key] = [];
            }

            $tmp = &$tmp[$key];
        }
        $tmp = $value;

        return $obj;
    }
775153
protected function getValue($key, array $array = array())
    {
        $keys = $this->parseKey($key);

        while (count($keys) > 0 and !is_null($array)) {
            $key = array_shift($keys);
            $array = isset($array[$key]) ? $array[$key] : null;
        }

        return $array;
    }
288169
public static function fillMissingKeys(array $array, $value = '')
    {
        if (count($array) === 0 || self::isAssociativeArray($array) === true) {
            return $array;
        }

        // sort and reset pointer to first element
        ksort($array);
        $min = key($array);
        end($array);
        $max = key($array);

        for ($i = $min; $i < $max; ++$i) {
            if (array_key_exists($i, $array) === false) {
                $array[$i] = $value;
            }
        }

        ksort($array);

        return $array;
    }
712016
public static function set( & $array, $key, $value)
	{
		if(is_null($key))
		{
			return $array = $value;
		}

		if(strpos($key, ".") !== false)
		{
			for( $i = 0, $keys = explode('.', $key), $count = count($keys); $i < $count; $i++ )
			{
				$key = $keys[$i];
				if( $i + 1 == $count )
				{
					break;
				}

				// If the key doesn't exist at this depth, we will just create an empty array
				// to hold the next value, allowing us to create the arrays to hold final
				// values at the correct depth. Then we'll keep digging into the array.
				if(! isset($array[$key]) || ! is_array($array[$key]))
				{
					$array[$key] = [];
				}

				$array = & $array[$key];
			}
		}

		$array[$key] = $value;

		return $array;
	}
405488
public function isError($key = null)
    {
        $value = $this->getError($key);
        return is_array($value) ? !empty($value) : isset($value);
    }
722090
public static function pluck($array, $value, $key = null)
    {
        $results = [];

        [$value, $key] = static::explodePluckParameters($value, $key);

        foreach ($array as $item) {
            $itemValue = data_get($item, $value);

            // If the key is "null", we will just append the value to the array and keep
            // looping. Otherwise we will key the array using the value of the key we
            // received from the developer. Then we'll return the final array form.
            if (is_null($key)) {
                $results[] = $itemValue;
            } else {
                $itemKey = data_get($item, $key);

                if (is_object($itemKey) && method_exists($itemKey, '__toString')) {
                    $itemKey = (string) $itemKey;
                }

                $results[$itemKey] = $itemValue;
            }
        }

        return $results;
    }
1074067
public static function set(array & $array, $key, $value)
    {
        if (strpos($key, '.') !== false) {
            $keys = explode('.', $key);
            $topKey = array_shift($keys);

            if (!isset($array[$topKey]) || !is_array($array[$topKey])) {
                $array[$topKey] = [];
            }

            static::set($array[$topKey], implode('.', $keys), $value);
        } else {
            $array[$key] = $value;
        }
    }
137905
public static function keyIsset($value, $key): bool
    {
        if (!static::isArrayAccessible($value)) {
            return false;
        }

        return isset($value[$key]);
    }
215983
public static function isEmpty($value): bool
    {
        return (!__::isArray($value) && !__::isObject($value)) || count((array)$value) === 0;
    }
736608
public static function set($array, $key, $value = null, $useDotSyntax = false)
    {
        // Normalize array
        $array = $array ?: [];

        // Check if key is empty
        if (StringHelper::emptyString($key, true)) {
            throw new InvalidArgumentException(__METHOD__ . ': Key cannot be empty');
        }

        /**
         * Split name using dots.
         *
         * Just checking whether the key doesn't have any dots
         * but $useDotSyntax is true by default.
         */
        $keyParts = explode('.', $key);
        $useDotSyntax = $useDotSyntax && count($keyParts) > 1;

        // Set simple value, without dot syntax
        if (!$useDotSyntax) {
            if (is_null($value) && isset($array[$key])) {
                unset($array[$key]);
            } elseif (!is_null($value)) {
                $array[$key] = $value;
            }
        } else {
            // Recursive call
            $base = $keyParts[0];
            unset($keyParts[0]);

            // Check if the base array exists
            if (!isset($array[$base])) {
                $array[$base] = [];
            }

            // Get key, base array and continue
            $key = implode('.', $keyParts);
            $innerArray = $array[$base];

            $array[$base] = static::set($innerArray, $key, $value, $useDotSyntax);
        }

        return $array;
    }
391179
protected function isNumericArray(array $value)
    {
        foreach (array_keys($value) as $key) {
            if (is_string($key)) {
                return false;
            }
        }

        return true;
    }
339738
public function contains($key, $value) {

		return in_array($value, $this->get($key, NULL, FALSE));

	}
1272701
public static function set(&$array, $key, $value)
    {
        $key = static::normalizeKey($key);

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

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

        foreach ($keys as $currentKey)
        {
            if (!array_key_exists($currentKey, $currentElement) || !is_array($currentElement[$currentKey]))
            {
                $currentElement[$currentKey] = [];
            }

            $currentElement =& $currentElement[$currentKey];
        }

        $currentElement[$last] = $value;

        return $array;
    }
121514
public static function remove_empty($arr)
    {
        if (empty($arr)) {
            return null;
        }
        foreach ($arr as $key => $value) {
            if (is_array($value)) {
                $arr[$key] = self::remove_empty($value);
            } else {
                if (empty($value)) {
                    unset($arr[$key]);
                } else {
                    $arr[$key] = $value;
                }
            }
        }
        return $arr;
    }