1<?php 2/** 3 * Matomo - free/libre analytics platform 4 * 5 * @link https://matomo.org 6 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later 7 * 8 */ 9 10namespace Piwik\Plugins\Marketplace\Input; 11use Piwik\Common; 12use Piwik\Plugin; 13use Exception; 14 15/** 16 */ 17class PluginName 18{ 19 private $requestParam = ''; 20 21 public function __construct($requestParam = 'pluginName') 22 { 23 $this->requestParam = $requestParam; 24 } 25 26 public function getPluginName() 27 { 28 $pluginName = Common::getRequestVar($this->requestParam, null, 'string'); 29 30 $this->dieIfPluginNameIsInvalid($pluginName); 31 32 return $pluginName; 33 } 34 35 private function dieIfPluginNameIsInvalid($pluginName) 36 { 37 if (!Plugin\Manager::getInstance()->isValidPluginName($pluginName)){ 38 throw new Exception('Invalid plugin name given'); 39 } 40 } 41 42} 43