<commit_before><?php
/**
 * @author <NAME> <<EMAIL>>
 * Date: 7/11/15
 * Time: 11:08 AM
 */

namespace CloudDrive\Cache;

use CloudDrive\Account;
use CloudDrive\Cache;
use CloudDrive\Node;
use PDO;
use SQLite3;

class SQLite implements Cache
{
    /**
     * @var \PDO
     */
    private $db;

    /**
     * @var \CloudDrive\Cache\SQLite
     */
    private static $instance;

    public function __construct($email, $cacheDir)
    {
        if (!file_exists("{$cacheDir}{$email}.db")) {
            $db = new SQLite3("{$cacheDir}{$email}.db");
            $db->exec(
                'CREATE TABLE nodes(
                    id VARCHAR PRIMARY KEY NOT NULL,
                    name VARCHAR NOT NULL,
                    kind VARCHAR NOT NULL,
                    md5 VARCHAR,
                    status VARCHAR,
                    parents VARCHAR,
                    created DATETIME NOT NULL,
                    modified DATETIME NOT NULL,
                    raw_data TEXT NOT NULL
                );'
            );
            $db->exec(<commit_msg>cache class now hands creation of necessary directories (since cache implementations such as MySQL won't need directories)<commit_after><?php
/**
 * @author <NAME> <<EMAIL>>
 * Date: 7/11/15
 * Time: 11:08 AM
 */

namespace CloudDrive\Cache;

use CloudDrive\Account;
use CloudDrive\Cache;
use CloudDrive\Node;
use PDO;
use SQLite3;

class SQLite implements Cache
{
    /**
     * @var \PDO
     */
    private $db;

    /**
     * @var \CloudDrive\Cache\SQLite
     */
    private static $instance;

    public function __construct($email, $cacheDir)
    {
        if (!file_exists($cacheDir)) {
            mkdir($cacheDir, 0777, true);
        }

        if (substr($cacheDir, -1) !== '/') {
            $cacheDir .= '/';
        }

        if (!file_exists("{$cacheDir}{$email}.db")) {
            $db = new SQLite3("{$cacheDir}{$email}.db");
            $db->exec(
                'CREATE TABLE nodes(
                    id VARCHAR PRIMARY KEY NOT NULL,
                    name VARCHAR NOT NULL,
                    kind VARCHAR NOT NULL,
                    md5 VARCHAR,
                    status VARCHAR,
                    parents VARCHAR,
                    created DATETIME NOT NULL,
                    modified DATETIME NOT NULL,
                    raw_data TEXT NOT NULL
                );'
            );
            $db->exec(
{'fraction_non_alphanumeric': 0.11268191268191269, 'fraction_numerical': 0.012058212058212059, 'mean_word_length': 1.4804123711340207, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, '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': '4530852', 'n_tokens_mistral': 719, 'n_tokens_neox': 641, 'n_words': 184}