1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?php
- /**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
- namespace Magento\Framework\Data\Argument\Interpreter;
- use Magento\Framework\Data\Argument\InterpreterInterface;
- use Magento\Framework\Stdlib\BooleanUtils;
- /**
- * Interpreter of string data type.
- */
- class BaseStringUtils implements InterpreterInterface
- {
- /**
- * @var BooleanUtils
- */
- private $booleanUtils;
- /**
- * BaseStringUtils constructor.
- *
- * @param BooleanUtils $booleanUtils
- */
- public function __construct(BooleanUtils $booleanUtils)
- {
- $this->booleanUtils = $booleanUtils;
- }
- /**
- * {@inheritdoc}
- * @return string
- * @throws \InvalidArgumentException
- */
- public function evaluate(array $data)
- {
- if (isset($data['value'])) {
- $result = $data['value'];
- if (!is_string($result)) {
- throw new \InvalidArgumentException('String value is expected.');
- }
- } else {
- $result = '';
- }
- return $result;
- }
- }
|