<commit_before><?php
/**
 * Examen 2016: Restaurant Project
 *
 * @since         1.0.0
 * @author        <NAME> <<EMAIL>>
 * @copyright (C) 2016 <NAME>. All rights reserved.
 * @license       MIT, see LICENCE
 */

namespace Nathalie\Exam16;

/**
 * Class ArticleRepo
 *
 * @package Nathalie\Exam16
 */
class ArticleRepo
{
    /** @var  \mysqli */
    private $database;

    /**
     * ArticleRepo constructor.
     *
     * @param $database
     */
    public function __construct($database)
    {
        $this->database = $database;
    }

    /**
     * @param integer $id
     *
     * @return object|\stdClass
     */
    public function getById($id)
    {
        $sql    = "SELECT * FROM article WHERE Article_ID=" . (int)$id;
        $result = mysqli_query($this->database, $sql, MYSQLI_ASSOC);

        return $result->fetch_object();
    }

    /**
     * @return object|\stdClass
     */
    public function getNewest()
    {
        $sql    = "SELECT * FROM article ORDER BY Article_Created DESC";
        $result = mysqli_query($this->database, $sql, MYSQLI_ASSOC);

        return $result->fetch_object();
    }

    /**
     * @return array
     */
    public function getAll()
    {
        $sql    = "SELECT * FROM article ORDER BY Article_Created DESC";
        $result = mysqli_query($this->database, $sql, MYSQLI_ASSOC);

        $all = [];

        foreach ($result->fetch_all(MYSQLI_ASSOC) as $row)
        {
            $all[] = (object)$row;
        }

        return $all;
    }

}<commit_msg>Added order direction to getAll()<commit_after><?php
/**
 * Examen 2016: Restaurant Project
 *
 * @since         1.0.0
 * @author        <NAME> <<EMAIL>>
 * @copyright (C) 2016 <NAME>. All rights reserved.
 * @license       MIT, see LICENCE
 */

namespace Nathalie\Exam16;

/**
 * Class ArticleRepo
 *
 * @package Nathalie\Exam16
 */
class ArticleRepo
{
    /** @var  \mysqli */
    private $database;

    /**
     * ArticleRepo constructor.
     *
     * @param $database
     */
    public function __construct($database)
    {
        $this->database = $database;
    }

    /**
     * @param integer $id
     *
     * @return object|\stdClass
     */
    public function getById($id)
    {
        $sql    = "SELECT * FROM article WHERE Article_ID=" . (int)$id;
        $result = mysqli_query($this->database, $sql, MYSQLI_ASSOC);

        return $result->fetch_object();
    }

    /**
     * @return object|\stdClass
     */
    public function getNewest()
    {
        $sql    = "SELECT * FROM article ORDER BY Article_Created DESC";
        $result = mysqli_query($this->database, $sql, MYSQLI_ASSOC);

        return $result->fetch_object();
    }

    /**
     * @return array#
     */
    public function getAll($orderDirection = 'DESC')
    {
        $sql    = "SELECT * FROM article ORDER BY Article_Created $orderDirection";
        $result = mysqli_query($this->database, $sql, MYSQLI_ASSOC);

        $all = [];

        foreach ($result->fetch_all(MYSQLI_ASSOC) as $row)
        {
            $all[] = (object)$row;
        }

        return $all;
    }

}
{'fraction_non_alphanumeric': 0.14221073044602456, 'fraction_numerical': 0.009696186166774402, 'mean_word_length': 2.0372914622178606, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 25, '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': '7432110', 'n_tokens_mistral': 1025, 'n_tokens_neox': 985, 'n_words': 221}