예제 #1
0
 /**
  * @param bool $lowerCase If =true, returned in lower case
  *
  * @return string Base name of method. <br/>
  *                Actions: without postfixes: *AndWait <br/>
  *                Accessors: without prefixes: store*, get*, is* <br/>
  *                Assertion: without prefixes: assert*, verify*, waitFor* <br/>
  * @throws \Exception   If not assigned
  *                      {@link type} of method
  */
 function getBaseName($lowerCase = false)
 {
     $baseName = null;
     switch ($this->type) {
         case static::TYPE_ACTION:
             $baseName = Helper::cutPostfix(['AndWait'], $this->name);
             break;
         case static::TYPE_ACCESSOR:
             $baseName = Helper::cutPrefix(['store', 'get', 'is'], $this->name);
             break;
         case static::TYPE_ASSERTION:
             $name = str_replace('Not', '', $this->name);
             $baseName = Helper::cutPrefix(['assert', 'verify', 'waitFor'], $name);
             break;
         default:
             $this::throwException('Cannot determine base name without assigned type of method');
     }
     return $lowerCase ? strtolower($baseName) : $baseName;
 }
 /**
  * Adds dot (if not exist) in to end of specified text (completion of sentence).
  *
  * @param string $text
  *
  * @return string   Trimmed text with dot in the end.
  */
 private function _addEndDotIfNotExist($text)
 {
     $endSymbols = '[' . join('', Helper::$endOfSentence) . ']';
     // symbol class like: [.!?]
     // find text like: "end</p>", "end </p>", "end  </p>"
     $regExpDotBeforeClosingTag = '/(?<!' . $endSymbols . '|' . $endSymbols . '\\s|' . $endSymbols . '\\s\\s)(?P<tag><\\/\\w+>)\\s*\\Z/';
     $testedText = trim(strip_tags($text));
     if ($testedText && !Helper::hasPostfix(Helper::$endOfSentence, $testedText)) {
         $postfix = preg_match($regExpDotBeforeClosingTag, $text, $m) ? $m['tag'] : '';
         $text = Helper::cutPostfix($postfix, rtrim($text)) . '.' . $postfix;
     }
     return $text;
 }