<commit_before><?php

namespace Faker\Provider;

class Computer extends \Faker\Provider\Base
{
    private static $macAddressDigits = array(
        "0", "1", "2", "3", "4", "5", "6", "7",
        "8", "9", "A", "B", "C", "D", "E", "F"
    );

    /**
     * @example '32:F1:39:2F:D6:18'
     */
    public static function macAddress()
    {
        $digits = self::$macAddressDigits;
        for ($i=0; $i<6; $i++) {
            shuffle($digits);
            $mac[] = $digits[0] . $digits[1];
        }
        $mac = implode(':', $mac);

        return $mac;
    }

    /**
     * @example '10.1.1.17'
     */
    public static function localIp()
    {
        $start = ['10','192'];

        $ip = $start[rand(0, 1)];

        if ($ip === '192') {
            $ip .= '.168';
        } else {
            $ip .= '.' . rand(0, 255);
        }

        $ip .= sprintf('.%s.%s', rand(0, 255), rand(0, 255));

        return $ip;
    }
}
<commit_msg>Use randomNumber instead of rand for better randomness. Use randomElement for picking elements from the allowed digits to make it possible for both digits of a MAC address block to be the same. Fixed for test failing on PHP 5.3.<commit_after><?php

namespace Faker\Provider;

class Computer extends \Faker\Provider\Base
{
    private static $macAddressDigits = array(
        "0", "1", "2", "3", "4", "5", "6", "7",
        "8", "9", "A", "B", "C", "D", "E", "F"
    );

    /**
     * @example '32:F1:39:2F:D6:18'
     */
    public static function macAddress()
    {
        for ($i=0; $i<6; $i++) {
            $mac[] = static::randomElement(self::$macAddressDigits) . static::randomElement(self::$macAddressDigits);
        }
        $mac = implode(':', $mac);

        return $mac;
    }

    /**
     * @example '10.1.1.17'
     */
    public static function localIp()
    {
        $start = array('10','192');

        $ip = $start[static::randomNumber(0, 1)];

        if ($ip === '192') {
            $ip .= '.168';
        } else {
            $ip .= '.' . static::randomNumber(0, 255);
        }

        $ip .= sprintf('.%s.%s', static::randomNumber(0, 255), static::randomNumber(0, 255));

        return $ip;
    }
}

{'fraction_non_alphanumeric': 0.2028453418999541, 'fraction_numerical': 0.04956402019274897, 'mean_word_length': 1.9700272479564032, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6590054', 'n_tokens_mistral': 815, 'n_tokens_neox': 755, 'n_words': 188}