Return the last item fo the passed value. (Last array item, last letter,
last object item.

@param mixed $value

@return mixed
541346
public static function last($value)
    {

        if (is_array($value) && $value) {
            return end($value);
        }

        if (!$value) {
            return null;
        }

        if (is_string($value)) {
            return mb_substr($value, -1);
        }

        if (!is_object($value)) {
            return null;
        }

        if (!$value instanceof Traversable) {
            return null;
        }

        $item = null;

        foreach ($value as $key=>$item) {
        }

        return $item;

    }
670033
public static function items($value)
	{
		$cache_key = md5($value);

		if (Arr::get(self::$_cache, $cache_key))
		{
			return self::$_cache[$cache_key];
		}

		self::$_cache[$cache_key] = array(
			'load'		=> FALSE,
			'items'	=> array()
		);

		foreach (explode(' - ', $value) as $items)
		{
			$new_item = array();

			if ( ! trim($items))
				continue;

			foreach (explode("\n", $items) as $key_value)
			{
				if ( ! trim($key_value))
					continue;

				$item = explode(':', $key_value);
				$new_item[trim($item[0])] = trim($item[1]);
			}

			self::$_cache[$cache_key]['items'][] = $new_item;
		}

		if (self::$_cache[$cache_key]['items'])
		{
			self::$_cache[$cache_key]['load'] = TRUE;
		}

		return self::$_cache[$cache_key];
	}
551762
private function parseValue($value)
    {
        if (is_string($value))
            return new String_($value);
        if (is_bool($value))
            return new ConstFetch(new Name([$value ? 'true' : 'false']));
        if (is_float($value))
            return new DNumber($value);
        if (is_numeric($value))
            return new LNumber($value);
        if (is_array($value)) {
            $items = [];
            foreach ($value as $key => $value) {
                $items[] = new ArrayItem(
                    $this->parseValue($value),
                    $this->parseValue($key)
                );
            }
            return new Array_($items);
        }
        return null;
    }
686437
public function get($value)
    {
        return $this->items[$value] ?? $this->items[explode('/', $value)[0].'/*'] ?? $this->items['*/*'] ?? $this->items['*'] ?? null;
    }
130873
public function push($key, $value)
    {
        $oldItems = $this->lastItems;

        $this->lastItems = array(
            $key => $value
        );

        if ($oldItems) {
            $this->lastItems = $this->lastItems + $oldItems;
        }

        return $this;
    }
314451
protected function cleanValue($value)
	{
		if (is_array($value)) {
			return array_map(function ($v) {
				return $this->cleanValue($v);
			}, $value);
		} else {
			return stripslashes($value);
		}
	}
1206341
public function last()
    {
        $keys = AccessHelper::collectionKeys($this->data);

        if (empty($keys)) {
            return null;
        }

        $value = $this->data[end($keys)] ? $this->data[end($keys)] : null;

        return AccessHelper::isCollectionType($value) ? new static($value, $this->options) : $value;
    }
821699
private function getValue($value)
    {
        if ($value === null) {
            return null;
        }

        if ($value instanceof String_ || $value instanceof LNumber || $value instanceof DNumber) {
            return $value->value;
        } elseif ($value instanceof ConstFetch) {
            $value = (string)$value->name;
            if ($value === 'null') {
                return null;
            } elseif ($value === 'true') {
                return true;
            } elseif ($value === 'false') {
                return false;
            }

            return $value;
        } elseif ($value instanceof Array_) {
            return $this->getArray($value);
        }

        return null;
    }
1181264
public function last(callable $callback = null, $default = null)
    {
        if (is_null($callback)) {
            if (!empty($this->items)) {
                return end($this->items);
            }
        }
        else {
            foreach (array_reverse($this->items, true) as $key => $value) {
                if (call_user_func($callback, $value, $key)) {
                    return $value;
                }
            }
        }

        return $default instanceof Closure ? $default() : $default;
    }
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;
		}
	}
625113
public function convert($value)
    {
        if (!is_object($value)) {
            return $value;
        }

        if ($value instanceof Collection) {
            return $value->map(function ($item) {
                return $this->formatter($item)->format($item);
            })->toArray();
        }

        return $this->formatter($value)->format($value);
    }
1083013
public function last(?string $key = null)
    {
        $value = $this->get($key);

        if (is_array($value)) {
            return end($value);
        }

        return $value;
    }
1090292
public function coollectizeItems($value)
    {
        $value = is_null($value) ? $this->items : $value;

        if (!$this->isArrayable($value)) {
            return $value;
        }

        $result = array_map(function ($value) {
            if ($this->isArrayable($value)) {
                return new static($value);
            }

            return $value;
        }, $this->getArrayableItems($value));

        return new static($result);
    }
886400
public function setLastName(?string $value) : Contact
    {

        if ($this->data['last_name'] !== $value) {
            $this->data['last_name'] = $value;
            $this->setModified('last_name');
        }

        return $this;
    }
1139999
public function getTransformedValue($value)
    {
        if(is_scalar($value) || (is_object($value) && method_exists($value, '__toString'))) {
            foreach($this->regex as $regex => $replace) {

                if(preg_match($regex, (string)$value))
                    return preg_replace($regex, $replace, $value);
            }
        }

       return $value;
    }
531257
public function prepend($value)
	{
		$value = $this->normalizeValue($value);

		array_unshift($this->items, $value);

		return $value;
	}
898388
public function remove($value) {
        $oldCollection = $this->getArrayCopy();
        if (!in_array($value, $oldCollection))
            return $this;

        $newCollection = array();
        foreach ($oldCollection as $val) {
            if ($val === $value)
                continue;

            $newCollection[] = $val;
        }
        $this->exchangeArray($newCollection);
        return $this;
    }