<commit_before><?php

namespace Paste\Storage;

use Paste\Entity\Paste;

class Storage
{
    protected $db;
    
    public function __construct(\Doctrine\DBAL\Connection $db)
    {
        $this->db = $db;
    }

    public function get($id)
    {
        $sql = 'SELECT id, paste, filename, token, timestamp FROM pastes WHERE token = ?';
        $stmt = $this->db->prepare($sql);
        $stmt->bindValue(1, $id);
        $stmt->execute();
        $result = $stmt->fetch();

        $paste = new Paste();
        $paste->setId($result['id']);<commit_msg>Return false if a paste cannot be found.<commit_after><?php

namespace Paste\Storage;

use Paste\Entity\Paste;

class Storage
{
    protected $db;
    
    public function __construct(\Doctrine\DBAL\Connection $db)
    {
        $this->db = $db;
    }

    public function get($id)
    {
        $sql = 'SELECT id, paste, filename, token, timestamp FROM pastes WHERE token = ?';
        $stmt = $this->db->prepare($sql);
        $stmt->bindValue(1, $id);
        $stmt->execute();
        $result = $stmt->fetch();

        // The statement failed to execute.
        if (false === $stmt->execute()) {
            throw new \RuntimeException('SQL statement failed to execute.');
        }

        // There are no results.
        if (false === $result = $stmt->fetch()) {
            return false;
        }

        // Assemble a paste model.
        $paste = new Paste();
        $paste->setId($result['id']);
{'fraction_non_alphanumeric': 0.1539509536784741, 'fraction_numerical': 0.0013623978201634877, 'mean_word_length': 2.1591397849462366, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, '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': '7032837', 'n_tokens_mistral': 446, 'n_tokens_neox': 438, 'n_words': 116}