<commit_before><?php

/*
 * This file is part of Mandango.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */

namespace Mandango\Logger;

/**
 * A loggable MongoDB.
 *
 * @author <NAME> <<EMAIL>>
 */
class LoggableMongoDB extends \MongoDB
{
    private $mongo;
    private $time;

    /**
     * Constructor.
     *
     * @param \Mandango\Logger\LoggableMongo $mongo A LoggableMongo instance.
     * @param string                         $name  The database name.
     */
    public function __construct(LoggableMongo $mongo, $name)
    {
        $this->mongo = $mongo;
        $this->time = new Time();

        return parent::__construct($mongo, $name);
    }

    /**
     * Returns the LoggableMongo.
     *
     * @return \Mandango\Logger\LoggableMongo The LoggableMongo.
     */
    public function getMongo()
    {
        return $this->mongo;
    }

    /**
     * Log.
     *
     * @param array $log The log.
     */
    public function log(array $log)
    {
        $this->mongo->log(array_merge(array(
            'database' => $this->__toString()
        ), $log));
    }

    /**
     * command.
     */
    public function command($command, array $options = array())
    {
        $this->time->start();
        $return = parent::command($command, $options);
        $time = $this->time->stop();

        $this->log(array(
            'type'    => 'command',
            'options' => $options,
            'time'    => $time,
        ));

        return $return;
    }

    /**
     * createCollection.
     */
    public function createCollection($name, $capped = false, $size = 0, $max = 0)
    {
        $this->time->start();
        $return = parent::createCollection($name, $capped, $size, $max);
        $time = $this->time->stop();

        $this->log(array(
            'type'   => 'createCollection',
            'name'   => $name,
            'capped' => $capped,
            'size'   => $size,
            'max'    => $max,
        ));

        return $return;
    }

    /**
     * createDbRef.
     */
    public function createDBRef($collection, $a)
    {
        $this->time->start();
        $return = parent::createDBRef($collection, $a);<commit_msg>added missing 'time'    => $time to log<commit_after><?php

/*
 * This file is part of Mandango.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */

namespace Mandango\Logger;

/**
 * A loggable MongoDB.
 *
 * @author <NAME> <<EMAIL>>
 */
class LoggableMongoDB extends \MongoDB
{
    private $mongo;
    private $time;

    /**
     * Constructor.
     *
     * @param \Mandango\Logger\LoggableMongo $mongo A LoggableMongo instance.
     * @param string                         $name  The database name.
     */
    public function __construct(LoggableMongo $mongo, $name)
    {
        $this->mongo = $mongo;
        $this->time = new Time();

        return parent::__construct($mongo, $name);
    }

    /**
     * Returns the LoggableMongo.
     *
     * @return \Mandango\Logger\LoggableMongo The LoggableMongo.
     */
    public function getMongo()
    {
        return $this->mongo;
    }

    /**
     * Log.
     *
     * @param array $log The log.
     */
    public function log(array $log)
    {
        $this->mongo->log(array_merge(array(
            'database' => $this->__toString()
        ), $log));
    }

    /**
     * command.
     */
    public function command($command, array $options = array())
    {
        $this->time->start();
        $return = parent::command($command, $options);
        $time = $this->time->stop();

        $this->log(array(
            'type'    => 'command',
            'options' => $options,
            'time'    => $time,
        ));

        return $return;
    }

    /**
     * createCollection.
     */
    public function createCollection($name, $capped = false, $size = 0, $max = 0)
    {
        $this->time->start();
        $return = parent::createCollection($name, $capped, $size, $max);
        $time = $this->time->stop();

        $this->log(array(
            'type'   => 'createCollection',
            'name'   => $name,
            'capped' => $capped,
            'size'   => $size,
            'max'    => $max,
            'time'    => $time,
        ));

        return $return;
    }

    /**
     * createDbRef.
     */
    public function createDBRef($collection, $a)
    {
        $this->time->start();
        $return = parent::createDBRef($collection, $a);
{'fraction_non_alphanumeric': 0.15713047247507586, 'fraction_numerical': 0.0008669267446900737, 'mean_word_length': 1.7834740651387213, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 71, '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': '7473208', 'n_tokens_mistral': 1475, 'n_tokens_neox': 1446, 'n_words': 326}