1
0

FileName.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2018 Daniel Kesselberg <mail@danielkesselberg.de>
  5. *
  6. * @license GNU AGPL version 3 or any later version
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU Affero General Public License as
  10. * published by the Free Software Foundation, either version 3 of the
  11. * License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU Affero General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. namespace OCA\WorkflowEngine\Check;
  23. use OCP\Files\Storage\IStorage;
  24. use OCP\IL10N;
  25. use OCP\IRequest;
  26. class FileName extends AbstractStringCheck {
  27. /** @var IRequest */
  28. protected $request;
  29. /** @var IStorage */
  30. protected $storage;
  31. /** @var string */
  32. protected $path;
  33. /**
  34. * @param IL10N $l
  35. * @param IRequest $request
  36. */
  37. public function __construct(IL10N $l, IRequest $request) {
  38. parent::__construct($l);
  39. $this->request = $request;
  40. }
  41. /**
  42. * @param IStorage $storage
  43. * @param string $path
  44. */
  45. public function setFileInfo(IStorage $storage, $path) {
  46. $this->storage = $storage;
  47. $this->path = $path;
  48. }
  49. /**
  50. * @return string
  51. */
  52. protected function getActualValue(): string {
  53. return basename($this->path);
  54. }
  55. /**
  56. * @param string $operator
  57. * @param string $checkValue
  58. * @param string $actualValue
  59. * @return bool
  60. */
  61. protected function executeStringCheck($operator, $checkValue, $actualValue): bool {
  62. if ($operator === 'is' || $operator === '!is') {
  63. $checkValue = mb_strtolower($checkValue);
  64. $actualValue = mb_strtolower($actualValue);
  65. }
  66. return parent::executeStringCheck($operator, $checkValue, $actualValue);
  67. }
  68. }