Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 16
0.00% covered (danger)
0.00%
0 / 7
CRAP
0.00% covered (danger)
0.00%
0 / 1
Header
0.00% covered (danger)
0.00%
0 / 16
0.00% covered (danger)
0.00%
0 / 7
56
0.00% covered (danger)
0.00%
0 / 1
 create
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 1
2
 fromStorageRow
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
 getRevisionType
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getWorkflowId
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getCollectionId
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getCollection
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getObjectId
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace Flow\Model;
4
5use Flow\Collection\HeaderCollection;
6use MediaWiki\User\User;
7
8/**
9 * @todo Header is just a summary to the discussion workflow, it could be just
10 * migrated to Summary revision with rev_change_type: create-header-summary,
11 * edit-header-summary
12 */
13class Header extends AbstractRevision {
14
15    /**
16     * @var UUID
17     */
18    protected $workflowId;
19
20    /**
21     * @param Workflow $workflow
22     * @param User $user
23     * @param string $content
24     * @param string $format wikitext|html
25     * @param string $changeType
26     * @return Header
27     */
28    public static function create( Workflow $workflow, User $user, $content, $format, $changeType = 'create-header' ) {
29        $obj = new self;
30        $obj->revId = UUID::create();
31        $obj->workflowId = $workflow->getId();
32        $obj->user = UserTuple::newFromUser( $user );
33        $obj->prevRevision = null; // no prior revision
34        $obj->setContent( $content, $format, $workflow->getArticleTitle() );
35        $obj->changeType = $changeType;
36        return $obj;
37    }
38
39    /**
40     * @param string[] $row
41     * @param Header|null $obj
42     * @return Header
43     */
44    public static function fromStorageRow( array $row, $obj = null ) {
45        /** @var Header $obj */
46        $obj = parent::fromStorageRow( $row, $obj );
47        '@phan-var Header $obj';
48        $obj->workflowId = UUID::create( $row['rev_type_id'] );
49        return $obj;
50    }
51
52    /**
53     * @return string
54     */
55    public function getRevisionType() {
56        return 'header';
57    }
58
59    /**
60     * @return UUID
61     */
62    public function getWorkflowId() {
63        return $this->workflowId;
64    }
65
66    /**
67     * @return UUID
68     */
69    public function getCollectionId() {
70        return $this->getWorkflowId();
71    }
72
73    /**
74     * @return HeaderCollection
75     */
76    public function getCollection() {
77        // @phan-suppress-next-line PhanTypeMismatchReturnSuperType
78        return HeaderCollection::newFromRevision( $this );
79    }
80
81    public function getObjectId() {
82        return $this->getWorkflowId();
83    }
84}