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