<commit_before><?php
declare(strict_types=1);

namespace ParagonIE\EasyDB;

use ParagonIE\EasyDB\Exception\{
    ConstructorFailed
};
use PDO;
use PDOException;
use function
    explode,
    is_string,
    str_contains;

/**
 * Class Factory
 *
 * @package ParagonIE\EasyDB
 */
abstract class Factory
{
    /**
     * Create a new EasyDB object based on PDO constructors
     *
     * @param string $dsn
     * @param ?string $username
     * @param ?string $password
     * @param array $options
     *
     * @throws ConstructorFailed
     *
     * @psalm-taint-sink user_secret $password
     */
    public static function create(
        string $dsn,
        string $username = null,
        string $password = null,
        array $options = []
    ): EasyDB {
        return static::fromArray([$dsn, $username, $password, $options]);
    }
    
    /**
     * Create a new EasyDB object from array of parameters
     *
     * @param array $config
     * @return EasyDB
     *
     * @throws ConstructorFailed
     */
    public static function fromArray(array $config): EasyDB
    {
        /** @var string $dsn */
        $dsn      = $config[0];
        /** @var string|null $username */
        $username = $config[1] ?? null;
        /** @var string|null $password */<commit_msg>Include return type<commit_after><?php
declare(strict_types=1);

namespace ParagonIE\EasyDB;

use ParagonIE\EasyDB\Exception\{
    ConstructorFailed
};
use PDO;
use PDOException;
use function
    explode,
    is_string,
    str_contains;

/**
 * Class Factory
 *
 * @package ParagonIE\EasyDB
 */
abstract class Factory
{
    /**
     * Create a new EasyDB object based on PDO constructors
     *
     * @param string $dsn
     * @param ?string $username
     * @param ?string $password
     * @param array $options
     * @return EasyDB
     *
     * @throws ConstructorFailed
     *
     * @psalm-taint-sink user_secret $password
     */
    public static function create(
        string $dsn,
        string $username = null,
        string $password = <PASSWORD>,
        array $options = []
    ): EasyDB {
        return static::fromArray([$dsn, $username, $password, $options]);
    }
    
    /**
     * Create a new EasyDB object from array of parameters
     *
     * @param array $config
     * @return EasyDB
     *
     * @throws ConstructorFailed
     */
    public static function fromArray(array $config): EasyDB
    {
        /** @var string $dsn */
        $dsn      = $config[0];
        /** @var string|null $username */
        $username = $config[1] ?? null;
        /** @var string|null $password */
{'fraction_non_alphanumeric': 0.11733128834355828, 'fraction_numerical': 0.0023006134969325155, 'mean_word_length': 2.2329615861214376, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '1496128', 'n_tokens_mistral': 792, 'n_tokens_neox': 783, 'n_words': 214}