Beispiel #1
0
 /**
  * @param string    $key
  * @param string    $value
  * @param Structure $structure
  * @param int       $maxKeyLength
  * @param int       $maxValueLength
  *
  * @return string
  */
 private static function printStructureLine($key, $value, Structure $structure, $maxKeyLength, $maxValueLength)
 {
     $result = '';
     $insertTab = $structure->getTab() ? true : false;
     $border = $structure->getBorder();
     if ($border) {
         $keyLength = Util::getVisibleStringLength($key);
         $missingKeyLength = $maxKeyLength - $keyLength;
         $fillingKeySpace = Util::buildPatternLine(' ', $missingKeyLength);
         $valueLength = Util::getVisibleStringLength($value);
         $missingValueLength = $maxValueLength - $valueLength;
         $fillingValueSpace = Util::buildPatternLine(' ', $missingValueLength);
         $result .= $insertTab ? $structure->getTab() : '';
         $result .= $border->getColumnCharacter() . ' ' . $key . $fillingKeySpace . ' ';
         $result .= $structure->getKeyToValueCharacter() . ' ' . $value . $fillingValueSpace . ' ';
         $result .= $border->getColumnCharacter() . PHP_EOL;
     } else {
         $keyLength = Util::getVisibleStringLength($key);
         $missingKeyLength = $maxKeyLength - $keyLength;
         $fillingKeySpace = Util::buildPatternLine(' ', $missingKeyLength);
         $result .= $insertTab ? $structure->getTab() : '';
         $result .= $key . $fillingKeySpace . ' ';
         $result .= $structure->getKeyToValueCharacter() . ' ' . $value;
         $result .= PHP_EOL;
     }
     return $result;
 }
Beispiel #2
0
 public function testGetters()
 {
     $borderMock = new Mock\Matks\Vivian\Border\Border('underline');
     $structure = new BaseStructure\Structure('array', 'a', 'b', 'c', $borderMock);
     $this->string($structure->getType())->isEqualTo('array')->string($structure->getIteratorCharacter())->isEqualTo('a')->string($structure->getTab())->isEqualTo('b')->string($structure->getKeyToValueCharacter())->isEqualTo('c')->object($structure->getBorder())->isEqualTo($borderMock);
 }