コード例 #1
0
ファイル: Version.php プロジェクト: thinframe/foundation
 /**
  * Parse version string
  *
  * @throws \ThinFrame\Foundation\Exception\InvalidArgumentException
  */
 private function parseVersion()
 {
     if (StaticStringy::startsWith($this->versionString, 'v')) {
         $this->versionString = StaticStringy::substr($this->versionString, 1);
     }
     if (strstr($this->versionString, '-')) {
         if (sscanf($this->versionString, '%d.%d.%d-%s', $this->major, $this->minor, $this->release, $this->suffix) != 4) {
             throw new InvalidArgumentException('Invalid version format ' . $this->versionString);
         }
     } else {
         if (sscanf($this->versionString, '%d.%d.%d', $this->major, $this->minor, $this->release) != 3) {
             throw new InvalidArgumentException('Invalid version format ' . $this->versionString);
         }
     }
 }
コード例 #2
0
ファイル: detail.php プロジェクト: snivs/semanti
    } else {
        return $data['timestamp'];
    }
}, 'headerOptions' => ['class' => 'sort-numerical text-align-center'], 'footerOptions' => ['class' => 'sort-numerical text-align-center font-weight-bold th'], 'contentOptions' => ['class' => 'nowrap font-size-10px text-align-center']], ['attribute' => 'level', 'value' => function ($data) {
    switch ($data['level']) {
        case Logger::LEVEL_ERROR:
            $class = 'label label-danger';
            break;
        case Logger::LEVEL_WARNING:
            $class = 'label label-warning';
            break;
        case Logger::LEVEL_INFO:
            $class = 'label label-primary';
            break;
        default:
            $class = 'label label-default';
            break;
    }
    return Html::tag('span', Logger::getLevelName($data['level']), ['class' => $class]);
}, 'format' => 'html', 'filter' => [Logger::LEVEL_TRACE => ' Trace ', Logger::LEVEL_INFO => ' Info ', Logger::LEVEL_WARNING => ' Warning ', Logger::LEVEL_ERROR => ' Error '], 'filterInputOptions' => ['class' => 'form-control chosen-select', 'id' => null, 'prompt' => ' All '], 'headerOptions' => ['class' => 'text-align-center'], 'footerOptions' => ['class' => 'text-align-center font-weight-bold th'], 'contentOptions' => ['class' => 'text-align-center']], ['attribute' => 'category', 'headerOptions' => ['class' => 'text-align-center'], 'footerOptions' => ['class' => 'text-align-center font-weight-bold th'], 'contentOptions' => ['class' => 'font-size-10px']], ['attribute' => 'message', 'value' => function ($data) {
    $description = Html::encode(is_string($data['message']) ? $data['message'] : VarDumper::export($data['message']));
    $message = '<a href="javascript:;" class="spoiler-title" data-title="" data-content="' . $description . '">' . Stringy::substr(Stringy::collapseWhitespace($description), 0, 60, 'UTF-8') . '...' . '</a>';
    $trace = '';
    if (!empty($data['trace'])) {
        $trace .= Html::ul($data['trace'], ['class' => 'trace', 'item' => function ($trace) {
            return "<li>{$trace['file']} ({$trace['line']})</li>";
        }]);
    }
    $message .= '<div class="spoiler-content"><strong>Message: </strong><br /><pre>' . $description . '</pre>' . (!empty($trace) ? '<br /><p><strong>Trace: </strong>' . $trace . '</p>' : '') . '</div>';
    return $message;
}, 'format' => 'html', 'options' => ['width' => '50%'], 'contentOptions' => ['class' => 'spoiler']]]]);
コード例 #3
0
 /**
  * @dataProvider substrProvider()
  */
 public function testSubstr($expected, $str, $start, $length = null, $encoding = null)
 {
     $result = S::substr($str, $start, $length, $encoding);
     $this->assertInternalType('string', $result);
     $this->assertEquals($expected, $result);
 }
コード例 #4
0
ファイル: StringyLoader.php プロジェクト: lablog/stringy
 public function substr($string, $start, $length = null)
 {
     return Stringy::substr($string, $start, $length);
 }