Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 10
0.00% covered (danger)
0.00%
0 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
CodePropChange
0.00% covered (danger)
0.00%
0 / 10
0.00% covered (danger)
0.00%
0 / 3
12
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 newFromRow
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 newFromData
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace MediaWiki\Extension\CodeReview\Backend;
4
5use stdClass;
6
7class CodePropChange {
8
9    public $attrib;
10
11    public $removed;
12
13    public $added;
14
15    public $user;
16
17    public $userText;
18
19    public $timestamp;
20
21    /**
22     * @var CodeRevision
23     */
24    public $rev;
25
26    /**
27     * @param CodeRevision $rev
28     */
29    public function __construct( $rev ) {
30        $this->rev = $rev;
31    }
32
33    /**
34     * @param CodeRevision $rev
35     * @param stdClass $row
36     * @return CodePropChange
37     */
38    public static function newFromRow( $rev, $row ) {
39        return self::newFromData( $rev, get_object_vars( $row ) );
40    }
41
42    /**
43     * @param CodeRevision $rev
44     * @param array $data
45     * @return CodePropChange
46     */
47    public static function newFromData( $rev, $data ) {
48        $change = new CodePropChange( $rev );
49        $change->attrib = $data['cpc_attrib'];
50        $change->removed = $data['cpc_removed'];
51        $change->added = $data['cpc_added'];
52        $change->user = $data['cpc_user'];
53        // We'd prefer the up to date user table name
54        $change->userText = $data['user_name'] ?? $data['cpc_user_text'];
55        $change->timestamp = wfTimestamp( TS_MW, $data['cpc_timestamp'] );
56        return $change;
57    }
58}