<commit_before><?php namespace ZN\DataTypes\Arrays;

use Arrays;

class GetElement implements GetElementInterface
{
    //--------------------------------------------------------------------------------------------------------
    //
    // Author     : <NAME> <<EMAIL>>
    // Site       : www.znframework.com
    // License    : The MIT License
    // Copyright  : (c) 2012-2016, znframework.com
    //
    //--------------------------------------------------------------------------------------------------------

    //--------------------------------------------------------------------------------------------------------
    // Get Last
    //--------------------------------------------------------------------------------------------------------
    //
    // @param array   $array
    // @param numeric $count
    // @param bool    $preserveKey
    //
    //--------------------------------------------------------------------------------------------------------
    public function last(Array $array, Int $count = 1, Bool $preserveKey = false)
    {
        if( $count <= 1 )
        {
            $array = end($array);
        }
        else
        {
            return Arrays::section($array, -$count, NULL, $preserveKey);
        }

        return $array;
    }

    //--------------------------------------------------------------------------------------------------------
    // Get First
    //--------------------------------------------------------------------------------------------------------
    //
    // @param array   $array
    // @param numeric $count
    // @param bool    $preserveKey
    //
    //--------------------------------------------------------------------------------------------------------
    public function first(Array $array, Int $count = 1, Bool $preserveKey = false)
    {
        if( $count <= 1 )
        {
            $array = $array[0];
        }
        else
        {
            return Arrays::section($array, 0, $count, $preserveKey);
        }

        return $array;
    }
}
<commit_msg>4.2.7 -> Updated Arrays Library<commit_after><?php namespace ZN\DataTypes\Arrays;

use Arrays;

class GetElement implements GetElementInterface
{
    //--------------------------------------------------------------------------------------------------------
    //
    // Author     : <NAME> <<EMAIL>>
    // Site       : www.znframework.com
    // License    : The MIT License
    // Copyright  : (c) 2012-2016, znframework.com
    //
    //--------------------------------------------------------------------------------------------------------

    //--------------------------------------------------------------------------------------------------------
    // Get Last
    //--------------------------------------------------------------------------------------------------------
    //
    // @param array   $array
    // @param numeric $count
    // @param bool    $preserveKey
    //
    //--------------------------------------------------------------------------------------------------------
    public function last(Array $array, Int $count = 1, Bool $preserveKey = false)
    {
        if( $count <= 1 )
        {
            $array = end($array) ?? NULL;
        }
        else
        {
            return Arrays::section($array, -$count, NULL, $preserveKey);
        }

        return $array;
    }

    //--------------------------------------------------------------------------------------------------------
    // Get First
    //--------------------------------------------------------------------------------------------------------
    //
    // @param array   $array
    // @param numeric $count
    // @param bool    $preserveKey
    //
    //--------------------------------------------------------------------------------------------------------
    public function first(Array $array, Int $count = 1, Bool $preserveKey = false)
    {
        if( $count <= 1 )
        {
        }
        else
        {
            return Arrays::section($array, 0, $count, $preserveKey);
        }

        return $array;
    }
}

{'fraction_non_alphanumeric': 0.4904645476772616, 'fraction_numerical': 0.007334963325183374, 'mean_word_length': 0.5146242132543503, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3395000', 'n_tokens_mistral': 813, 'n_tokens_neox': 766, 'n_words': 182}