Completed
Push — master ( 9ed240...526dfe )
by Razon
02:55
created

ArticleMetaFactory::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 10
cc 1
nc 1
nop 2
crap 1
1
<?php
2
namespace App\Factory;
3
4
use App\Model\ArticleMeta;
5
use Yii;
6
7
class ArticleMetaFactory
8
{
9
    public static function findByArticleId(int $articleId): ?ArticleMeta
10
    {
11
        return ArticleMeta::findOne([
0 ignored issues
show
Bug Best Practice introduced by
The expression return App\Model\Article...cle_id' => $articleId)) returns the type yii\db\ActiveRecord which includes types incompatible with the type-hinted return App\Model\ArticleMeta|null.
Loading history...
12
            'article_id' => $articleId,
13
        ]);
14
    }
15
16 2
    public static function create(int $articleId, string $content): ArticleMeta
17
    {
18 2
        return new ArticleMeta([
19 2
            'article_id' => $articleId,
20 2
            'content' => $content,
21
        ]);
22
    }
23
}
24