<commit_before><?php

namespace ArtLibs;


class Article
{

    /**
     * @param Application $app
     * @param null $state
     * @param null $category_id
     * @return bool
     */
    public static function getArticles(Application $app, $state = null, $category_id = null)
    {
        $cond = array();

        if ($category_id !== null) {
            $cond['category_id'] = (int)$category_id;
        }

        if ($state !== null) {
            $cond['state'] = $state;
        }

        try {
            $query = $app->getDataManager()->getDataManager()->from("articles");
            $query->where($cond);
            $q = $query->orderBy('date_inserted ASC')->fetchAll();
        } catch (\PDOException $ex) {
            $app->getErrorManager()->addMessage("Error : " . $ex->getMessage());
            return false;
        }

        return $q;
    }

    /**
     * @param $aid
     * @param $app
     * @return mixed
     */
    public static function getArticleById($aid, Application $app)
    {
        if (!isset($aid)) {
            return false;
        }

        try {
            $query = $app->getDataManager()->getDataManager()->from("articles")
                ->where(array("id" => $aid))
                ->fetch();
        } catch (\PDOException $ex) {
            $app->getErrorManager()->addMessage("Error : " . $ex->getMessage());
            return false;
        }

        return $query;
    }

    /**
     * @param $article_data
     * @param $aid
     * @param $app
     * @return bool
     */
    public static function updateArticle($article_data, $aid, Application $app)
    {<commit_msg>Minor changes<commit_after><?php

namespace ArtLibs;


class Article
{

    /**
     * @param Application $app
     * @param null $state
     * @param null $category_id
     * @return array|bool
     */
    public static function getArticles(Application $app, $state = null, $category_id = null)
    {
        $cond = array();

        if ($category_id !== null) {
            $cond['category_id'] = (int)$category_id;
        }

        if ($state !== null) {
            $cond['state'] = $state;
        }

        try {
            $query = $app->getDataManager()->getDataManager()->from("articles");
            $query->where($cond);
            $q = $query->orderBy('date_inserted ASC')->fetchAll();
        } catch (\PDOException $ex) {
            $app->getErrorManager()->addMessage("Error : " . $ex->getMessage());
            return false;
        }

        return $q;
    }

    /**
     * @param $aid
     * @param Application $app
     * @return bool|mixed
     */
    public static function getArticleById($aid, Application $app)
    {
        if (!isset($aid)) {
            return false;
        }

        try {
            $query = $app->getDataManager()->getDataManager()->from("articles")
                ->where(array("id" => $aid))
                ->fetch();
        } catch (\PDOException $ex) {
            $app->getErrorManager()->addMessage("Error : " . $ex->getMessage());
            return false;
        }

        return $query;
    }

    /**
     * @param $article_data
     * @param $aid
     * @param $app
     * @return bool
     */
    public static function updateArticle($article_data, $aid, Application $app)
    {
{'fraction_non_alphanumeric': 0.15759050806206268, 'fraction_numerical': 0.0, 'mean_word_length': 1.7840812870448772, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 39, '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': '2837455', 'n_tokens_mistral': 959, 'n_tokens_neox': 937, 'n_words': 200}