本文整理汇总了PHP中Str类的典型用法代码示例。如果您正苦于以下问题:PHP Str类的具体用法?PHP Str怎么用?PHP Str使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Str类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: parse
public function parse(RequestInterface $request, ResponseInterface $response, MapInterface $attributes) : MapInterface
{
$start = $this->clock->now();
if (!$this->isHtml($attributes)) {
return $attributes;
}
$document = $this->reader->read($response->body());
try {
$metas = (new Elements('meta'))((new Head())($document));
} catch (ElementNotFoundException $e) {
return $attributes;
}
$meta = $metas->filter(function (ElementInterface $meta) : bool {
return $meta->attributes()->contains('name') && $meta->attributes()->get('name')->value() === 'apple-itunes-app' && $meta->attributes()->contains('content');
});
if ($meta->size() !== 1) {
return $attributes;
}
$content = $meta->current()->attributes()->get('content')->value();
$content = new Str($content);
if (!$content->match(self::PATTERN)) {
return $attributes;
}
$matches = $content->getMatches(self::PATTERN);
return $attributes->put(self::key(), new Attribute(self::key(), (string) $matches['uri'], $this->clock->now()->elapsedSince($start)->milliseconds()));
}
开发者ID:innmind,项目名称:crawler,代码行数:26,代码来源:IosParser.php
示例2: make
public function make(Str $name, Str $value) : HeaderInterface
{
if ((string) $name->toLower() !== 'content-type') {
throw new InvalidArgumentException();
}
$matches = $value->getMatches('~(?<type>[\\w*]+)/(?<subType>[\\w*]+)(?<params>(; ?\\w+=\\"?[\\w\\-.]+\\"?)+)?~');
return new ContentType(new ContentTypeValue((string) $matches->get('type'), (string) $matches->get('subType'), $this->buildParams($matches->hasKey('params') ? $matches->get('params') : new Str(''))));
}
开发者ID:innmind,项目名称:http,代码行数:8,代码来源:ContentTypeFactory.php
示例3: buildSubPropertyCondition
private function buildSubPropertyCondition(ComparatorInterface $specification) : SequenceInterface
{
$prop = new Str($specification->property());
$pieces = $prop->split('.');
$var = (new Str('entity_'))->append($pieces->pop()->join('_'));
$key = $var->append('_')->append((string) $pieces->last())->append((string) $this->count);
return new Sequence(sprintf('%s %s %s', $var->append('.')->append((string) $pieces->last()), $specification->sign(), $key->prepend('{')->append('}')), new Collection([(string) $key => $specification->value()]));
}
开发者ID:innmind,项目名称:neo4j-onm,代码行数:8,代码来源:AggregateVisitor.php
示例4: test_it_replaces_between_haystack_with_closure
public function test_it_replaces_between_haystack_with_closure()
{
$Str = new Str();
$outcome = $Str->replaceBetween('something @here(...) and @here(...)', '@here', function ($between) {
return "[ {$between} ]";
});
assertEquals('something [ ... ] and [ ... ]', $outcome);
}
开发者ID:alpas29,项目名称:cms,代码行数:8,代码来源:StrTest.php
示例5: fromString
public static function fromString(string $type, Types $types) : TypeInterface
{
$type = new Str($type);
if (!$type->match(self::PATTERN)) {
throw new InvalidArgumentException();
}
return new self($types->build((string) $type->getMatches(self::PATTERN)->get('inner')));
}
开发者ID:innmind,项目名称:rest-client,代码行数:8,代码来源:SetType.php
示例6: buildSubPropertyMapping
private function buildSubPropertyMapping(ComparatorInterface $specification) : MapInterface
{
$prop = new Str($specification->property());
$pieces = $prop->split('.');
$var = (new Str('entity_'))->append($pieces->pop()->join('_'));
$key = $var->append('_')->append((string) $pieces->last());
return (new Map('string', SequenceInterface::class))->put((string) $var, new Sequence(new Collection([(string) $pieces->last() => (string) $key->prepend('{')->append('}')]), new Collection([(string) $key => $specification->value()])));
}
开发者ID:innmind,项目名称:neo4j-onm,代码行数:8,代码来源:AggregateVisitor.php
示例7: make
public function make(Str $name, Str $value) : HeaderInterface
{
if ((string) $name->toLower() !== 'content-language') {
throw new InvalidArgumentException();
}
$values = new Set(HeaderValueInterface::class);
foreach ($value->split(',') as $language) {
$values = $values->add(new ContentLanguageValue((string) $language->trim()));
}
return new ContentLanguage($values);
}
开发者ID:innmind,项目名称:http,代码行数:11,代码来源:ContentLanguageFactory.php
示例8: make
public function make(Str $name, Str $value) : HeaderInterface
{
if ((string) $name->toLower() !== 'allow') {
throw new InvalidArgumentException();
}
$values = new Set(HeaderValueInterface::class);
foreach ($value->split(',') as $allow) {
$values = $values->add(new AllowValue((string) $allow->trim()->toUpper()));
}
return new Allow($values);
}
开发者ID:innmind,项目名称:http,代码行数:11,代码来源:AllowFactory.php
示例9: make
public function make(Str $name, Str $value) : HeaderInterface
{
if ($this->factories->contains((string) $name->toLower())) {
return $this->factories->get((string) $name->toLower())->make($name, $value);
}
$values = new Set(HeaderValueInterface::class);
foreach ($value->split(',') as $headerValue) {
$values = $values->add(new HeaderValue((string) $headerValue->trim()));
}
return new Header((string) $name, $values);
}
开发者ID:innmind,项目名称:http,代码行数:11,代码来源:DefaultFactory.php
示例10: make
public function make(Str $name, Str $value) : HeaderInterface
{
if ((string) $name->toLower() !== 'accept') {
throw new InvalidArgumentException();
}
$values = new Set(HeaderValueInterface::class);
foreach ($value->split(',') as $accept) {
$matches = $accept->getMatches('~(?<type>[\\w*]+)/(?<subType>[\\w*]+)(?<params>(; ?\\w+=\\"?[\\w\\-.]+\\"?)+)?~');
$values = $values->add(new AcceptValue((string) $matches->get('type'), (string) $matches->get('subType'), $this->buildParams($matches->hasKey('params') ? $matches->get('params') : new Str(''))));
}
return new Accept($values);
}
开发者ID:innmind,项目名称:http,代码行数:12,代码来源:AcceptFactory.php
示例11: make
public function make(Str $name, Str $value) : HeaderInterface
{
if ((string) $name->toLower() !== 'accept-charset') {
throw new InvalidArgumentException();
}
$values = new Set(HeaderValueInterface::class);
foreach ($value->split(',') as $accept) {
$matches = $accept->getMatches('~(?<charset>[a-zA-Z0-9\\-_:\\(\\)]+)(; ?q=(?<quality>\\d+(\\.\\d+)?))?~');
$values = $values->add(new AcceptCharsetValue((string) $matches->get('charset'), new Quality($matches->hasKey('quality') ? (double) (string) $matches->get('quality') : 1)));
}
return new AcceptCharset($values);
}
开发者ID:innmind,项目名称:http,代码行数:12,代码来源:AcceptCharsetFactory.php
示例12: make
public function make(Str $name, Str $value) : HeaderInterface
{
if ((string) $name->toLower() !== 'accept-language') {
throw new InvalidArgumentException();
}
$values = new Set(HeaderValueInterface::class);
foreach ($value->split(',') as $accept) {
$matches = $accept->getMatches('~(?<lang>([a-zA-Z0-9]+(-[a-zA-Z0-9]+)*|\\*))(; ?q=(?<quality>\\d+(\\.\\d+)?))?~');
$values = $values->add(new AcceptLanguageValue((string) $matches->get('lang'), new Quality($matches->hasKey('quality') ? (double) (string) $matches->get('quality') : 1)));
}
return new AcceptLanguage($values);
}
开发者ID:innmind,项目名称:http,代码行数:12,代码来源:AcceptLanguageFactory.php
示例13: make
public function make(Str $name, Str $value) : HeaderInterface
{
if ((string) $name->toLower() !== 'cache-control') {
throw new InvalidArgumentException();
}
$splits = $value->split(',');
$values = new Set(HeaderValueInterface::class);
foreach ($splits as $split) {
$split = $split->trim();
switch (true) {
case $split->match('~^max-age=\\d+$~'):
$values = $values->add(new CacheControlValue\MaxAge((int) (string) $split->substring(8)));
break;
case $split->match('~^max-stale(=\\d+)?$~'):
$values = $values->add(new CacheControlValue\MaxStale($split->length() > 10 ? (int) (string) $split->substring(10) : 0));
break;
case $split->match('~^min-fresh=\\d+$~'):
$values = $values->add(new CacheControlValue\MinimumFresh((int) (string) $split->substring(10)));
break;
case (string) $split === 'must-revalidate':
$values = $values->add(new CacheControlValue\MustRevalidate());
break;
case $split->match('~^no-cache(="?\\w+"?)?$~'):
$matches = $split->getMatches('~^no-cache(="?(?<field>\\w+)"?)?$~');
$values = $values->add(new CacheControlValue\NoCache($matches->hasKey('field') ? (string) $matches->get('field') : ''));
break;
case (string) $split === 'no-store':
$values = $values->add(new CacheControlValue\NoStore());
break;
case (string) $split === 'no-transform':
$values = $values->add(new CacheControlValue\NoTransform());
break;
case (string) $split === 'only-if-cached':
$values = $values->add(new CacheControlValue\OnlyIfCached());
break;
case $split->match('~^private(="?\\w+"?)?$~'):
$matches = $split->getMatches('~^private(="?(?<field>\\w+)"?)?$~');
$values = $values->add(new CacheControlValue\PrivateCache($matches->hasKey('field') ? (string) $matches->get('field') : ''));
break;
case (string) $split === 'proxy-revalidate':
$values = $values->add(new CacheControlValue\ProxyRevalidate());
break;
case (string) $split === 'public':
$values = $values->add(new CacheControlValue\PublicCache());
break;
case $split->match('~^s-maxage=\\d+$~'):
$values = $values->add(new CacheControlValue\SharedMaxAge((int) (string) $split->substring(9)));
break;
}
}
return new CacheControl($values);
}
开发者ID:innmind,项目名称:http,代码行数:52,代码来源:CacheControlFactory.php
示例14: make
public function make(Str $name, Str $value) : HeaderInterface
{
if ((string) $name->toLower() !== 'link') {
throw new InvalidArgumentException();
}
$links = new Set(HeaderValueInterface::class);
foreach ($value->split(',') as $link) {
$matches = $link->trim()->getMatches('~^<(?<url>\\S+)>(?<params>(; ?\\w+=\\"?[\\w\\-.]+\\"?)+)?$~');
$params = $this->buildParams($matches->hasKey('params') ? $matches->get('params') : new Str(''));
$links = $links->add(new LinkValue(Url::fromString((string) $matches->get('url')), $params->contains('rel') ? $params->get('rel')->value() : 'related', $params->contains('rel') ? $params->remove('rel') : $params));
}
return new Link($links);
}
开发者ID:innmind,项目名称:http,代码行数:13,代码来源:LinkFactory.php
示例15: getPaymentCart
public function getPaymentCart()
{
$values = Session::get('payment');
foreach ($values as $key => $value) {
$product[$key]['name'] = $value['name'];
$price = round((int) $value['price'] / 21270);
$product[$key]['price'] = $price;
$product[$key]['quantity'] = 1;
$product[$key]['product_id'] = $value['id'];
}
$tmpTransaction = new TmpTransaction();
$st = Str::random(16);
$baseUrl = URL::to('/product/payment/return?order_id=' . $st);
// $value[1]['name'] = "sản phẩm 1";
// $value[1]['price'] = "20000";
// $value[1]['quantity'] = "1";
// $value[1]['product_id'] = "3";
// $value[2]['name'] = "sản phẩm 2";
// $value[2]['price'] = "20000";
// $value[2]['quantity'] = "1";
// $value[2]['product_id'] = "3";
$payment = $this->makePaymentUsingPayPalCart($product, 'USD', "{$baseUrl}&success=true", "{$baseUrl}&success=false");
$tmpTransaction->order_id = $st;
$tmpTransaction->payment_id = $payment->getId();
$tmpTransaction->save();
header("Location: " . $this->getLink($payment->getLinks(), "approval_url"));
exit;
return "index";
}
开发者ID:VoDongMy,项目名称:VoDongMy,代码行数:29,代码来源:PaymentController.php
示例16: create
/**
* Show the form for creating a new resource.
* GET /ob/create
*
* @return Response
*/
public function create()
{
$validate = LeaveOB::validate(Input::all());
if ($validate->passes()) {
if (Input::get('totalleaves') <= 0.0 or Input::get('totalleaves') === 'NaN') {
$message = 'Please select correct date!';
return Redirect::to('applyob')->with('error_message', $message);
} else {
$lastrow = LeaveOB::orderBy('created_at', 'desc')->first();
}
$data = new LeaveOB();
$data->employee_id = Auth::user()->employee_id;
if ($lastrow == null) {
$data->leave_id = Str::random(8);
} else {
$data->leave_id = Str::random(8) . $lastrow->id;
}
$data->days_of_leave = Input::get('totalleaves');
$data->wdays_of_leave = Input::get('totalleave');
$data->date_from = Input::get('date_from');
$data->time_from = Input::get('time_from');
$data->date_to = Input::get('date_to');
$data->time_to = Input::get('time_to');
$data->company = Input::get('company');
$data->address = Input::get('address');
$data->reason = Input::get('reason');
$data->save();
return Redirect::to('applyob')->with('message', 'Your Application for Official Business (OB) is successfully send.Please Check Your Notification box to see if your leave has been approved.');
} else {
return Redirect::to('applyob')->withErrors($validate);
}
}
开发者ID:joshbrosas,项目名称:stileaveapp,代码行数:38,代码来源:OBController.php
示例17: __construct
public function __construct($query, &$conn, &$orm = null)
{
$this->conn = $conn;
$this->res = null;
$this->orm = $orm;
$this->rowOrm = null;
$this->success = false;
$this->fields = null;
$this->EOF = true;
$this->BOF = true;
$this->index = 0;
$this->count = 0;
$this->insertID = 0;
$type = strtolower(substr(trim(str_replace("\n", " ", $query)), 0, 7));
$typeIsSelect = $type == "select ";
$typeIsShowTables = $type == "show ta";
$typeIsInsert = $type == "insert ";
$query = Str::finish($query, ";");
if ($this->res = @mysql_query($query, $this->conn->res)) {
$this->success = true;
if ($typeIsSelect || $typeIsShowTables) {
$this->count = mysql_num_rows($this->res);
$this->moveFirst();
} else {
if ($typeIsInsert) {
$this->insertID = mysql_insert_id($this->conn->res);
}
}
} else {
trigger_error("SQL error: " . $query . "\n<br><b>'" . mysql_error($this->conn->res) . "'</b>");
}
}
开发者ID:jura-php,项目名称:jura,代码行数:32,代码来源:MysqlRecordSet.php
示例18: setReplyToEmail
public static function setReplyToEmail($user, $email)
{
Cache::forget('replyToEmail_' . $user->id);
return Cache::rememberForever('replyToEmail_' . $user->id, function () use($email) {
return Str::lower($email);
});
}
开发者ID:shinichi81,项目名称:Nifty-Newsletter,代码行数:7,代码来源:Setting.php
示例19: __construct
/**
* Make a new Keyword Value Object.
*
* @param \Orchestra\Support\Keyword|string $value
*/
public function __construct($value)
{
$this->value = $value;
if (is_string($value)) {
$this->slug = trim(Str::slug($value, '-'));
}
}
开发者ID:DavidIWilson,项目名称:site1,代码行数:12,代码来源:Keyword.php
示例20: update
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function update($id)
{
$familia = Familia::findOrFail($id);
$validator = Familia::validator(Input::all());
if ($validator->fails()) {
return Redirect::back()->withErrors($validator)->withInput();
}
$datos = Input::all();
if (Input::file('foto')) {
$file = Input::file('foto');
$destinationPath = 'uploads/images/';
$filename = Str::random(20) . '.' . $file->getClientOriginalExtension();
$mimeType = $file->getMimeType();
$extension = $file->getClientOriginalExtension();
$upload_success = $file->move($destinationPath, $filename);
if ($familia->foto != 'fam.jpg') {
File::delete($destinationPath . $familia->foto);
}
$datos['foto'] = $filename;
} else {
unset($datos['foto']);
}
$familia->update($datos);
Session::flash('message', 'Actualizado Correctamente');
Session::flash('class', 'success');
return Redirect::to('/dashboard/familia');
}
开发者ID:bjohnmer,项目名称:sf,代码行数:33,代码来源:FamiliasController.php
注:本文中的Str类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论