Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

12345678910111213141516171819202122232425262728293031323334353637383940
  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. }