@@ 62-72 (lines=11) @@ | ||
59 | * @param array $data Data for entry fields. Keys correspond to the setters, e.g. key 'content' calls `setContent()`. |
|
60 | * @throws InvalidArgumentException If an argument is invalid. |
|
61 | */ |
|
62 | public function __construct( array $data = array() ) { |
|
63 | $data = $data + array( 'timestamp' => 'now' ); |
|
64 | foreach ( $data as $k => $v ) { |
|
65 | $func = array( $this, 'set' . ucfirst( $k ) ); |
|
66 | if ( is_callable( $func ) ) { |
|
67 | $func( $v ); |
|
68 | } else { |
|
69 | throw new InvalidArgumentException( __METHOD__ . ": Unrecognized data item \"$k\"." ); |
|
70 | } |
|
71 | } |
|
72 | } |
|
73 | ||
74 | /** |
|
75 | * Compare two ChangeEntry objects. |
@@ 70-80 (lines=11) @@ | ||
67 | * @param array $data Data for other entry fields. Keys correspond to the setters, e.g. key 'link' calls `setLink()`. |
|
68 | * @throws InvalidArgumentException If an argument is invalid. |
|
69 | */ |
|
70 | public function __construct( $version, array $data = array() ) { |
|
71 | $data = array( 'version' => $version ) + $data + array( 'timestamp' => 'now' ); |
|
72 | foreach ( $data as $k => $v ) { |
|
73 | $func = array( $this, 'set' . ucfirst( $k ) ); |
|
74 | if ( is_callable( $func ) ) { |
|
75 | $func( $v ); |
|
76 | } else { |
|
77 | throw new InvalidArgumentException( __METHOD__ . ": Unrecognized data item \"$k\"." ); |
|
78 | } |
|
79 | } |
|
80 | } |
|
81 | ||
82 | /** |
|
83 | * Get the version. |