DataObject.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /**
  3. *
  4. * Copyright © Magento, Inc. All rights reserved.
  5. * See COPYING.txt for license details.
  6. */
  7. namespace Magento\Framework\Data\Argument\Interpreter;
  8. use Magento\Framework\Data\Argument\InterpreterInterface;
  9. use Magento\Framework\Stdlib\BooleanUtils;
  10. class DataObject implements InterpreterInterface
  11. {
  12. /**
  13. * @var \Magento\Framework\Stdlib\BooleanUtils
  14. */
  15. protected $booleanUtils;
  16. /**
  17. * @param BooleanUtils $booleanUtils
  18. */
  19. public function __construct(BooleanUtils $booleanUtils)
  20. {
  21. $this->booleanUtils = $booleanUtils;
  22. }
  23. /**
  24. * Compute and return effective value of an argument
  25. *
  26. * @param array $data
  27. * @return mixed
  28. * @throws \InvalidArgumentException
  29. * @throws \UnexpectedValueException
  30. */
  31. public function evaluate(array $data)
  32. {
  33. $result = ['instance' => $data['value']];
  34. if (isset($data['shared'])) {
  35. $result['shared'] = $this->booleanUtils->toBoolean($data['shared']);
  36. }
  37. return $result;
  38. }
  39. }