Element.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. /**
  7. * Config element model
  8. */
  9. namespace Magento\Framework\App\Config;
  10. /**
  11. * @api
  12. * @since 100.0.2
  13. */
  14. class Element extends \Magento\Framework\Simplexml\Element
  15. {
  16. /**
  17. * Enter description here...
  18. *
  19. * @param string $var
  20. * @param boolean $value
  21. * @return boolean
  22. * @SuppressWarnings(PHPMD.ShortMethodName)
  23. */
  24. public function is($var, $value = true)
  25. {
  26. $flag = $this->{$var};
  27. if ($value === true) {
  28. $flag = strtolower((string)$flag);
  29. if (!empty($flag) && 'false' !== $flag && 'off' !== $flag) {
  30. return true;
  31. } else {
  32. return false;
  33. }
  34. }
  35. return !empty($flag) && 0 === strcasecmp($value, (string)$flag);
  36. }
  37. /**
  38. * Enter description here...
  39. *
  40. * @return string
  41. */
  42. public function getClassName()
  43. {
  44. if ($this->class) {
  45. $model = (string)$this->class;
  46. } elseif ($this->model) {
  47. $model = (string)$this->model;
  48. } else {
  49. return false;
  50. }
  51. return $model;
  52. }
  53. }