src/Headzoo/Core/Arrays.php
public static function conjunct(array $array, $conjunction = self::DEFAULT_CONJUNCTION, callable $callback = null)
    {
        self::swapCallable($conjunction, $callback, self::DEFAULT_CONJUNCTION, false);
        if (null !== $callback) {
            $array = array_map($callback, $array);
        }
        if (count($array) > 1) {
            $final     = array_pop($array);
            $sentence  = join(self::DEFAULT_SEPARATOR, $array);
            $separator = trim(self::DEFAULT_SEPARATOR);
            $sentence  = "{$sentence}{$separator} {$conjunction} {$final}";
        } else {
            $sentence = array_pop($array);
        }
        
        return $sentence;
    }
public static function conjunct(array $array, $conjunction = self::DEFAULT_CONJUNCTION, callable $callback = null)
    {
        self::swapCallable($conjunction, $callback, self::DEFAULT_CONJUNCTION, false);
        if (null !== $callback) {
            $array = array_map($callback, $array);
        }
        if (count($array) > 1) {
            $final     = array_pop($array);
            $sentence  = join(self::DEFAULT_SEPARATOR, $array);
            $separator = trim(self::DEFAULT_SEPARATOR);
            $sentence  = "{$sentence}{$separator} {$conjunction} {$final}";
        } else {
            $sentence = array_pop($array);
        }
        
        return $sentence;
    }
public static function conjunct ( array $ array , $ conjunction = self :: DEFAULT_CONJUNCTION , callable $ callback = null ) { self :: swapCallable ( $ conjunction , $ callback , self :: DEFAULT_CONJUNCTION , false ) ; if ( null !== $ callback ) { $ array = array_map ( $ callback , $ array ) ; } if ( count ( $ array ) > 1 ) { $ final = array_pop ( $ array ) ; $ sentence = join ( self :: DEFAULT_SEPARATOR , $ array ) ; $ separator = trim ( self :: DEFAULT_SEPARATOR ) ; $ sentence = "{$sentence}{$separator} {$conjunction} {$final}" ; } else { $ sentence = array_pop ( $ array ) ; } return $ sentence ; }
Joins an array of values with a final conjunction

Similar to the Arrays::join() method, this method combines the array values using the default separator,
and joins the final item in the array with a conjunction. An array of strings can be turned into
a list of items, for example ["food", "water", "shelter"] becomes "food, water, and shelter".

Examples:
```php
$array = [
"headzoo",
"joe",
"sam"
];

echo Arrays::conjunct($array);
// Outputs: headzoo, joe, and sam

echo Arrays::conjunct($array, "and", 'Headzoo\Core\Strings::quote');
// Outputs: 'headzoo', 'joe', and 'sam'

// The default conjunction will be used when the middle argument is omitted, and the
// last argument is callable object.
echo Arrays::conjunct($array, 'Headzoo\Core\Strings::quote');
```

@param  array    $array        The array of values to join
@param  string   $conjunction  The conjunction word to use
@param  callable $callback     Optional callback applied to each element of the array
@return string
Joins an array of values with a final conjunction