mirror of
https://gh.wpcy.net/https://github.com/YahnisElsts/plugin-update-checker.git
synced 2026-04-27 23:41:41 +08:00
Move most GitHub and BitBucket stuff to a general "VCS checker" class and put service-specific logic in API classes that follow a common interface.
Rationale: Upon further reflection, there's no need to have different theme & plugin checker implementations for each Git hosting service. The overall update detection algorithm stays the same. Only the API and authentication are different.
Not entirely happy with the code duplication in Vcs_PluginUpdateChecker and Vcs_ThemeUpdateChecker. Traits would be one solution, but can't use that in PHP 5.2. There's probably a "good enough" way to achieve the same thing through composition, but I haven't figured it out yet.
For private GH repositories, use setAuthentication('access_token_here') instead of setAccessToken().
49 lines
No EOL
1 KiB
PHP
49 lines
No EOL
1 KiB
PHP
<?php
|
|
if ( !class_exists('Puc_v4_Vcs_Reference', false) ):
|
|
|
|
/**
|
|
* This class represents a VCS branch or tag. It's intended as a read only, short-lived container
|
|
* that only exists to provide a limited degree of type checking.
|
|
*
|
|
* @property string $name
|
|
* @property string|null version
|
|
* @property string $downloadUrl
|
|
* @property string $updated
|
|
*
|
|
* @property string|null $changelog
|
|
* @property int|null $downloadCount
|
|
*/
|
|
class Puc_v4_Vcs_Reference {
|
|
private $properties = array();
|
|
|
|
public function __construct($properties = array()) {
|
|
$this->properties = $properties;
|
|
}
|
|
|
|
/**
|
|
* @param string $name
|
|
* @return mixed|null
|
|
*/
|
|
function __get($name) {
|
|
return array_key_exists($name, $this->properties) ? $this->properties[$name] : null;
|
|
}
|
|
|
|
/**
|
|
* @param string $name
|
|
* @param mixed $value
|
|
*/
|
|
function __set($name, $value) {
|
|
$this->properties[$name] = $value;
|
|
}
|
|
|
|
/**
|
|
* @param string $name
|
|
* @return bool
|
|
*/
|
|
function __isset($name) {
|
|
return isset($this->properties[$name]);
|
|
}
|
|
|
|
}
|
|
|
|
endif; |