Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 8 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
| QtiItemCompilerAssetBlacklist | |
0.00% |
0 / 8 |
|
0.00% |
0 / 4 |
56 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
6 | |||
| isBlacklisted | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
12 | |||
| getBlacklist | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setBlacklist | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | /* |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * as published by the Free Software Foundation; under version 2 |
| 7 | * of the License (non-upgradable). |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 | * |
| 18 | * Copyright (c) 2013 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT); |
| 19 | * |
| 20 | * |
| 21 | */ |
| 22 | |
| 23 | namespace oat\taoQtiItem\model\compile; |
| 24 | |
| 25 | use oat\oatbox\service\ConfigurableService; |
| 26 | |
| 27 | /** |
| 28 | * Short description of class oat\taoQtiItem\model\compile\QtiItemCompilerAssetBlacklist |
| 29 | * |
| 30 | * @access public |
| 31 | * @author Antoine Robin, <antoine@taotesting.com> |
| 32 | * @package taoQTI |
| 33 | */ |
| 34 | class QtiItemCompilerAssetBlacklist extends ConfigurableService |
| 35 | { |
| 36 | public const SERVICE_ID = 'taoQtiItem/compileBlacklist'; |
| 37 | |
| 38 | public const BLACKLIST = 'blacklist'; |
| 39 | |
| 40 | private $blacklist = []; |
| 41 | |
| 42 | /** |
| 43 | * QtiItemCompilerAssetBlacklist constructor. |
| 44 | * @param array $options |
| 45 | */ |
| 46 | public function __construct(array $options = []) |
| 47 | { |
| 48 | parent::__construct($options); |
| 49 | $this->blacklist = ($this->hasOption(self::BLACKLIST)) ? $this->getOption(self::BLACKLIST) : []; |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Allow to know if a path is blacklisted or not |
| 54 | * @param string $assetPath |
| 55 | * @return bool |
| 56 | */ |
| 57 | public function isBlacklisted($assetPath) |
| 58 | { |
| 59 | foreach ($this->blacklist as $pattern) { |
| 60 | if (preg_match($pattern, $assetPath) === 1) { |
| 61 | return true; |
| 62 | } |
| 63 | } |
| 64 | return false; |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * Get the list of blacklisted pattern |
| 69 | * @return array |
| 70 | */ |
| 71 | public function getBlacklist() |
| 72 | { |
| 73 | return $this->blacklist; |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * set new list of blacklisted pattern |
| 78 | * @param $blacklist |
| 79 | */ |
| 80 | public function setBlacklist($blacklist) |
| 81 | { |
| 82 | $this->blacklist = $blacklist; |
| 83 | } |
| 84 | } |