Beispiel #1
0
 public function filter($value)
 {
     // Берем stem
     $stem = new Stem();
     $value = $stem->filter($value);
     // Сортируем слова по алфавиту
     $wordsArray = array_unique(explode(' ', $value));
     asort($wordsArray);
     return sha1(implode(' ', $wordsArray));
 }
Beispiel #2
0
 public function filter($value)
 {
     $value = parent::filter($value);
     $value = preg_replace('#\\s+#', ' ', $value);
     // Сортируем слова по алфавиту
     $wordsArray = array_unique(explode(' ', $value));
     asort($wordsArray);
     return implode(' ', $wordsArray);
 }
Beispiel #3
0
 /**
  * @param Stem $stemOne
  * @param Stem $stemTwo
  */
 protected function drawComparison(Stem $stemOne, Stem $stemTwo, HeadTube $headTube)
 {
     $comparison = $stemOne->compare($stemTwo, $headTube);
     $line = 1;
     $color = imagecolorallocate($this->image, 255, 255, 255);
     foreach ($comparison as $text) {
         imagettftext($this->image, 12, 0, 5, $line * 20, $color, $this->fontPath, $text);
         $line++;
     }
 }
Beispiel #4
0
 /**
  * @param Stem $stem
  * @param HeadTube $headTube
  *
  * @return array
  */
 public function compare(Stem $stem, HeadTube $headTube)
 {
     // Calculate the offset the spacers will cause in the stem
     $currentSpacersOffsetX = $headTube->getLength($this->getSpacers()) - $headTube->getLength();
     $currentSpacersOffsetY = $headTube->getHeight($this->getSpacers()) - $headTube->getHeight();
     $currentStemLength = $this->getLength() - $currentSpacersOffsetX;
     $currentStemHeight = $this->getHeight() + $currentSpacersOffsetY;
     $comparedSpacersOffsetX = $headTube->getLength($stem->getSpacers()) - $headTube->getLength();
     $comparedSpacersOffsetY = $headTube->getHeight($stem->getSpacers()) - $headTube->getHeight();
     $comparedStemLength = $stem->getLength() - $comparedSpacersOffsetX;
     $comparedStemHeight = $stem->getHeight() + $comparedSpacersOffsetY;
     $length = number_format($currentStemLength - $comparedStemLength, 1);
     // $lengthStr = 'The 1st stem is ' . abs($length) . 'mm longerlonger than de 2nd one';
     $lengthStr = 'longer';
     if ($length < 0) {
         $lengthStr = 'shorter';
     }
     $height = number_format($currentStemHeight - $comparedStemHeight, 1);
     $heightStr = 'higher';
     if ($height < 0) {
         $heightStr = 'lower';
     }
     $comparison = ['length' => 'The red stem is ' . abs($length) . 'mm ' . $lengthStr . ' than de blue one', 'height' => 'The red stem is ' . abs($height) . 'mm ' . $heightStr . ' than de blue one'];
     return $comparison;
 }