releaseAssetsEnabled = true; $this->assetFilterRegex = $nameRegex; $this->releaseAssetPreference = $preference; } /** * Disable release assets. * * @return void * @noinspection PhpUnused -- Public API */ public function disableReleaseAssets() { $this->releaseAssetsEnabled = false; $this->assetFilterRegex = null; } /** * Does the specified asset match the name regex? * * @param mixed $releaseAsset Data type and structure depend on the host/API. * @return bool */ protected function matchesAssetFilter($releaseAsset) { if ( $this->assetFilterRegex === null ) { //The default is to accept all assets. return true; } $name = $this->getFilterableAssetName($releaseAsset); if ( !is_string($name) ) { return false; } return (bool)preg_match($this->assetFilterRegex, $releaseAsset->name); } /** * Get the part of asset data that will be checked against the filter regex. * * @param mixed $releaseAsset * @return string|null */ abstract protected function getFilterableAssetName($releaseAsset); } endif;