Blog::newArticle()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 5
rs 10
1
<?php
2
3
namespace Helix\Shopify;
4
5
use Helix\Shopify\Base\AbstractEntity;
6
use Helix\Shopify\Base\AbstractEntity\CrudTrait;
7
use Helix\Shopify\Base\AbstractEntity\MetafieldTrait;
8
use Helix\Shopify\Blog\Article;
9
10
/**
11
 * A blog.
12
 *
13
 * @see https://shopify.dev/docs/admin-api/rest/reference/online-store/blog
14
 *
15
 * @method string   getCommentable          ()
16
 * @method string   getCreatedAt            ()
17
 * @method mixed    getFeedburner           ()
18
 * @method string   getFeedburnerLocation   ()
19
 * @method string   getHandle               ()
20
 * @method string   getTags                 ()
21
 * @method string   getTitle                ()
22
 * @method string   getUpdatedAt            ()
23
 *
24
 * @method $this    setCommentable          (string $mode)
25
 * @method $this    setHandle               (string $handle)
26
 * @method $this    setTags                 (string $csv)
27
 * @method $this    setTitle                (string $title)
28
 */
29
class Blog extends AbstractEntity
30
{
31
32
    use CrudTrait;
33
    use MetafieldTrait;
34
35
    const TYPE = 'blog';
36
    const DIR = 'blogs';
37
38
    const COMMENTS_CLOSED = 'no';
39
    const COMMENTS_MODERATED = 'moderate';
40
    const COMMENTS_OPEN = 'yes';
41
42
    /**
43
     * Factory.
44
     *
45
     * @return Article
46
     */
47
    public function newArticle()
48
    {
49
        assert($this->hasId());
50
        return $this->api->factory($this, Article::class, [
51
            'blog_id' => $this->getId()
52
        ]);
53
    }
54
}