当前位置: 首页>>代码示例>>PHP>>正文


PHP Timestamp::makeNow方法代码示例

本文整理汇总了PHP中Timestamp::makeNow方法的典型用法代码示例。如果您正苦于以下问题:PHP Timestamp::makeNow方法的具体用法?PHP Timestamp::makeNow怎么用?PHP Timestamp::makeNow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Timestamp的用法示例。


在下文中一共展示了Timestamp::makeNow方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: associate

 /**
  * "associate" mode request
  *
  * @param $server to make association with (usually obtained from OpenIdCredentials)
  * @param $manager - dao-like association manager
  * @return OpenIdConsumerAssociation
  **/
 public function associate(HttpUrl $server, OpenIdConsumerAssociationManager $manager)
 {
     Assert::isTrue($server->isValid());
     if ($association = $manager->findByServer($server)) {
         return $association;
     }
     $dhParameters = new DiffieHellmanParameters($this->numberFactory->makeNumber(self::DIFFIE_HELLMAN_G), $this->numberFactory->makeNumber(self::DIFFIE_HELLMAN_P));
     $keyPair = DiffieHellmanKeyPair::generate($dhParameters, $this->randomSource);
     $request = HttpRequest::create()->setMethod(HttpMethod::post())->setUrl($server)->setPostVar('openid.ns', self::NAMESPACE_2_0)->setPostVar('openid.mode', 'associate')->setPostVar('openid.assoc_type', self::ASSOCIATION_TYPE)->setPostVar('openid.session_type', 'DH-SHA1')->setPostVar('openid.dh_modulus', base64_encode($dhParameters->getModulus()->toBinary()))->setPostVar('openid.dh_gen', base64_encode($dhParameters->getGen()->toBinary()))->setPostVar('openid.dh_consumer_public', base64_encode($keyPair->getPublic()->toBinary()));
     $response = $this->httpClient->setFollowLocation(true)->send($request);
     if ($response->getStatus()->getId() != HttpStatus::CODE_200) {
         throw new OpenIdException('bad response code from server');
     }
     $result = $this->parseKeyValueFormat($response->getBody());
     if (empty($result['assoc_handle'])) {
         throw new OpenIdException('can\\t live without handle');
     }
     if (!isset($result['assoc_type']) || $result['assoc_type'] !== self::ASSOCIATION_TYPE) {
         throw new OpenIdException('bad association type');
     }
     if (!isset($result['expires_in']) || !is_numeric($result['expires_in'])) {
         throw new OpenIdException('bad expires');
     }
     if (isset($result['session_type']) && $result['session_type'] == 'DH-SHA1' && isset($result['dh_server_public'])) {
         $secret = sha1($keyPair->makeSharedKey($this->numberFactory->makeFromBinary(base64_decode($result['dh_server_public'])))->toBinary(), true) ^ base64_decode($result['enc_mac_key']);
     } elseif (empty($result['session_type']) && isset($result['mac_key'])) {
         $secret = base64_decode($result['mac_key']);
     } else {
         throw new OpenIdException('no secret in answer');
     }
     return $manager->makeAndSave($result['assoc_handle'], $result['assoc_type'], $secret, Timestamp::makeNow()->modify('+ ' . $result['expires_in'] . ' seconds'), $server);
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:39,代码来源:OpenIdConsumer.class.php

示例2: testDayDifference

 public function testDayDifference()
 {
     $today = Date::makeToday();
     $this->dayDifferenceTest($today, $today, 0);
     $timestamp = Timestamp::makeNow();
     $this->dayDifferenceTest($timestamp, $timestamp, 0);
     $left = Date::create('2008-01-12');
     $right = Date::create('2008-01-13');
     $this->dayDifferenceTest($left, $right, 1);
     $left = Date::create('2008-01-12');
     $right = Date::create('2009-01-13');
     $this->dayDifferenceTest($left, $right, 367);
     $left = Date::create('2008-01-12');
     $right = Date::create('2008-01-11');
     $this->dayDifferenceTest($left, $right, -1);
     $left = Timestamp::create('2008-01-12 01:23:00');
     $right = Timestamp::create('2008-01-13 13:01:17');
     $this->dayDifferenceTest($left, $right, 1);
     // change time from winter to summer
     $left = Timestamp::create('2008-03-29 02:00:00');
     $right = Timestamp::create('2008-03-30 02:00:00');
     $this->dayDifferenceTest($left, $right, 1);
     $left = Timestamp::create('2008-03-29 03:00:00');
     $right = Timestamp::create('2008-03-30 03:00:00');
     $this->dayDifferenceTest($left, $right, 1);
     // unsolved giv's case
     // $left = Timestamp::create('2008-10-25 03:00:00');
     // $right = Timestamp::create('2008-10-26 02:59:00');
     // $this->dayDifferenceTest($left, $right, 0);
     return $this;
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:31,代码来源:DateTest.class.php

示例3: testSleeping

 public function testSleeping()
 {
     $stamp = Timestamp::makeNow();
     $serializedStamp = serialize($stamp);
     $unserializedStamp = unserialize($serializedStamp);
     $this->assertEquals($stamp->getDay(), $unserializedStamp->getDay());
     $this->assertEquals($stamp->getMonth(), $unserializedStamp->getMonth());
     $this->assertEquals($stamp->getYear(), $unserializedStamp->getYear());
     $this->assertEquals($stamp->getMinute(), $unserializedStamp->getMinute());
     $this->assertEquals($stamp->getSecond(), $unserializedStamp->getSecond());
 }
开发者ID:rero26,项目名称:onphp-framework,代码行数:11,代码来源:TimestampTest.class.php

示例4: testIpAddressProperty

 public function testIpAddressProperty()
 {
     foreach (DBTestPool::me()->getPool() as $db) {
         DBPool::me()->setDefault($db);
         $city = TestCity::create()->setName('Khimki');
         TestCity::dao()->add($city);
         $userWithIp = TestUser::create()->setCredentials(Credentials::create()->setNickName('postgreser')->setPassword(sha1('postgreser')))->setLastLogin(Timestamp::makeNow())->setRegistered(Timestamp::makeNow())->setCity($city)->setIp(IpAddress::create('127.0.0.1'));
         TestUser::dao()->add($userWithIp);
         $this->assertTrue($userWithIp->getId() >= 1);
         $this->assertTrue($userWithIp->getIp() instanceof IpAddress);
         $plainIp = DBPool::me()->getByDao(TestUser::dao())->queryColumn(OSQL::select()->get('ip')->from(TestUser::dao()->getTable())->where(Expression::eq('id', $userWithIp->getId())));
         $this->assertEquals($plainIp[0], $userWithIp->getIp()->toString());
         $count = Criteria::create(TestUser::dao())->add(Expression::eq('ip', IpAddress::create('127.0.0.1')))->addProjection(Projection::count('*', 'count'))->getCustom('count');
         $this->assertEquals($count, 1);
     }
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:16,代码来源:IpDBTest.class.php

示例5: testQueueConsumer

 public function testQueueConsumer()
 {
     $c = new AMQPPecl(AMQPCredentials::createDefault());
     $channel = $c->createChannel(1);
     $channel->exchangeDeclare(self::EXCHANGE_NAME, AMQPExchangeConfig::create()->setType(new AMQPExchangeType(AMQPExchangeType::DIRECT))->setDurable(true));
     $inQueueCount = $channel->queueDeclare(self::QUEUE_NAME, AMQPQueueConfig::create()->setDurable(true));
     $this->assertSame(0, $inQueueCount);
     $channel->queueBind(self::QUEUE_NAME, self::EXCHANGE_NAME, self::ROUTING_KEY);
     //cleanup
     $channel->queuePurge(self::QUEUE_NAME);
     for ($i = 1; $i <= self::COUNT_OF_PUBLISH; $i++) {
         $channel->basicPublish(self::EXCHANGE_NAME, self::ROUTING_KEY, AMQPOutgoingMessage::create()->setBody("message {$i}")->setTimestamp(Timestamp::makeNow())->setAppId(__CLASS__)->setMessageId($i)->setContentEncoding('utf-8'));
     }
     $consumer = new AMQPTestCaseQueueConsumer($channel);
     $channel->basicConsume(self::QUEUE_NAME, false, $consumer);
     $i = 0;
     while (true) {
         $message = $consumer->getNextDelivery();
         //send acknowledge to RabbitMQ
         $channel->basicAck($message->getDeliveryTag(), false);
         $i++;
         $this->assertSame($consumer->getConsumerTag(), $message->getConsumerTag());
         $this->assertEquals($i, $message->getMessageId());
         $this->assertEquals(__CLASS__, $message->getAppId());
         $this->assertEquals("message {$i}", $message->getBody());
         if ($i == self::COUNT_OF_PUBLISH) {
             break;
         }
     }
     $channel->basicCancel($consumer->getConsumerTag());
     //observer logic test
     $this->assertSame('ABBBBBC', $consumer->getCheckString());
     //drop channels and close connection
     $c->disconnect();
     $c = new AMQPPecl(AMQPCredentials::createDefault());
     $channel = $c->createChannel(1);
     $channel->exchangeDeclare(self::EXCHANGE_NAME, AMQPExchangeConfig::create()->setType(new AMQPExchangeType(AMQPExchangeType::DIRECT))->setDurable(true));
     //queue must be empty, because we sent acknowledge
     $inQueueCount = $channel->queueDeclare(self::QUEUE_NAME, AMQPQueueConfig::create()->setDurable(true));
     $this->assertSame(0, $inQueueCount);
     //cleanup
     $channel->queuePurge(self::QUEUE_NAME);
 }
开发者ID:rero26,项目名称:onphp-framework,代码行数:43,代码来源:AMQPPeclTest.class.php

示例6: publishMessages

 /**
  * @param AMQPChannelInterface $channel
  * @param bool $check
  * @param string $key
  * @param string $queueName
  */
 protected function publishMessages(AMQPChannelInterface $channel, $check = true, $label = 'basic')
 {
     for ($i = 1; $i <= self::COUNT_OF_PUBLISH; $i++) {
         $channelInterface = $channel->basicPublish(self::$queueList[$label]['exchange'], self::$queueList[$label]['key'], AMQPOutgoingMessage::create()->setBody("message {$i}")->setTimestamp(Timestamp::makeNow())->setAppId(__CLASS__)->setMessageId($i)->setContentEncoding('utf-8'));
         if ($check) {
             $this->assertInstanceOf('AMQPChannelInterface', $channelInterface);
         }
     }
     if ($check) {
         $this->checkMessageCount($channel, $label);
     }
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:18,代码来源:AMQPPeclTest.class.php

示例7: __construct

 public function __construct()
 {
     $this->date = Timestamp::makeNow();
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:4,代码来源:LogRecord.class.php

示例8: testSleeping

 public function testSleeping()
 {
     $stamp = Timestamp::makeNow();
     $serializedStamp = serialize($stamp);
     $unserializedStamp = unserialize($serializedStamp);
     $this->assertEquals($stamp->getDay(), $unserializedStamp->getDay());
     $this->assertEquals($stamp->getMonth(), $unserializedStamp->getMonth());
     $this->assertEquals($stamp->getYear(), $unserializedStamp->getYear());
     $this->assertEquals($stamp->getMinute(), $unserializedStamp->getMinute());
     $this->assertEquals($stamp->getSecond(), $unserializedStamp->getSecond());
     $stamp = Timestamp::create('2039-01-05 12:14:05 Europe/Moscow');
     $serializedStamp = serialize($stamp);
     $unserializedStamp = unserialize($serializedStamp);
     $this->assertEquals($stamp->getDay(), $unserializedStamp->getDay());
     $this->assertEquals($stamp->getMonth(), $unserializedStamp->getMonth());
     $this->assertEquals($stamp->getYear(), $unserializedStamp->getYear());
     $this->assertEquals($stamp->getMinute(), $unserializedStamp->getMinute());
     $this->assertEquals($stamp->getSecond(), $unserializedStamp->getSecond());
     $stamp = Timestamp::create('1899-12-31 16:07:45 Europe/London');
     $serializedStamp = serialize($stamp);
     $unserializedStamp = unserialize($serializedStamp);
     $this->assertEquals($stamp->getDay(), $unserializedStamp->getDay());
     $this->assertEquals($stamp->getMonth(), $unserializedStamp->getMonth());
     $this->assertEquals($stamp->getYear(), $unserializedStamp->getYear());
     $this->assertEquals($stamp->getMinute(), $unserializedStamp->getMinute());
     $this->assertEquals($stamp->getSecond(), $unserializedStamp->getSecond());
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:27,代码来源:TimestampTest.class.php

示例9: __construct

 public function __construct(Timestamp $timestamp = null)
 {
     $this->timestamp = $timestamp ?: Timestamp::makeNow();
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:4,代码来源:TextMessage.class.php


注:本文中的Timestamp::makeNow方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。