You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
957B

  1. <?php
  2. /**
  3. * @link http://www.yiiframework.com/
  4. * @copyright Copyright (c) 2008 Yii Software LLC
  5. * @license http://www.yiiframework.com/license/
  6. */
  7. namespace yii\debug\components\search\matchers;
  8. use yii\helpers\VarDumper;
  9. /**
  10. * Checks if the given value is exactly or partially same as the base one.
  11. *
  12. * @author Mark Jebri <mark.github@yandex.ru>
  13. * @since 2.0
  14. */
  15. class SameAs extends Base
  16. {
  17. /**
  18. * @var boolean if partial match should be used.
  19. */
  20. public $partial = false;
  21. /**
  22. * @inheritdoc
  23. */
  24. public function match($value)
  25. {
  26. if (!is_scalar($value)) {
  27. $value = VarDumper::export($value);
  28. }
  29. if ($this->partial) {
  30. return mb_stripos($value, $this->baseValue, 0, \Yii::$app->charset) !== false;
  31. } else {
  32. return strcmp(mb_strtoupper($this->baseValue, \Yii::$app->charset), mb_strtoupper($value, \Yii::$app->charset)) === 0;
  33. }
  34. }
  35. }