<commit_before><?php

namespace common\services\implementations;

use common\models\Blog;
use common\models\search\BlogSearch;
use common\services\interfaces\IBlogService;
use yii\data\ActiveDataProvider;
use yii\web\NotFoundHttpException;

class BlogService implements IBlogService
{

    /**
     * @param array $params
     * @return ActiveDataProvider
     */
    public function search(array $params) : ActiveDataProvider
    {
        $searchModel = new BlogSearch();
        $dataProvider = $searchModel->search($params);

        return $dataProvider;
    }

    /**
     * @return Blog
     */
    public function createBlank() : Blog
    {
        return new Blog();
    }

    /**
     * @param Blog $blog
     * @return bool
     */
    public function save(Blog $blog) : bool
    {
        return $blog->save(false);
    }

    /**
     * @param int $id
     * @return Blog
     * @throws NotFoundHttpException
     */
    public function get(int $id) : Blog
    {
        $model = Blog::findOne($id);

        if ($model === null) {
            throw new NotFoundHttpException();
        }

        return $model;
    }
}<commit_msg>Witty_CMS-7 Add created user for blog<commit_after><?php

namespace common\services\implementations;

use common\models\Blog;
use common\models\search\BlogSearch;
use common\services\interfaces\IBlogService;
use yii\data\ActiveDataProvider;
use yii\web\NotFoundHttpException;

class BlogService implements IBlogService
{

    /**
     * @param array $params
     * @return ActiveDataProvider
     */
    public function search(array $params) : ActiveDataProvider
    {
        $searchModel = new BlogSearch();
        $dataProvider = $searchModel->search($params);

        return $dataProvider;
    }

    /**
     * @return Blog
     */
    public function createBlank() : Blog
    {
        $model = new Blog();
        $model->created_by = \Yii::$app->user->id;

        return $model;
    }

    /**
     * @param Blog $blog
     * @return bool
     */
    public function save(Blog $blog) : bool
    {
        return $blog->save(false);
    }

    /**
     * @param int $id
     * @return Blog
     * @throws NotFoundHttpException
     */
    public function get(int $id) : Blog
    {
        $model = Blog::findOne($id);

        if ($model === null) {
            throw new NotFoundHttpException();
        }

        return $model;
    }
}
{'fraction_non_alphanumeric': 0.12025052192066805, 'fraction_numerical': 0.0004175365344467641, 'mean_word_length': 2.22911051212938, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 10, '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': '1207938', 'n_tokens_mistral': 718, 'n_tokens_neox': 697, 'n_words': 163}