YahnisElsts/wp-update-server — pull request #21 by jrfnl (2014-09-28 21:43:53+00:00)
Title: Split off metadata

As - unlike with the `Headers` class -, the static methods in the Package class can not easily be overloaded, I'd suggest splitting them off into a separate `Metadata` class which can be overloaded.

This will make it a lot easier to add additional information to the metadata for a package.
All you need to do is extend the Metadata class and overload the $cacheTime $headerMap, $readmeMap and/or constructor to add additional data.
You will of course also need to overload the Package::fromArchive() method to use your extended class rather than the original, but as it's now a small method, it doesn't break the upgrade path as much as before.

Simple example code for how this could now be overloaded:
```php
class My_Metadata extends Wpup_Metadata {

protected $headerMapExtra = array(
'Text Domain' => 'textdomain',
);

protected $readmeMapExtra = array(
'short_description',
);

public function __construct( $slug, $filename, Wpup_Cache $cache = null ) {
$this->headerMap = array_merge( $this->headerMap, $this->headerMapExtra );
$this->readmeMap = array_merge( $this->readmeMap, $this->readmeMapExtra );

parent::__construct( $slug, $filename, $cache );

// Add additional metadata
$this->metadata['type'] = $this->packageInfo['type'];
}
}
```