コード例 #1
0
ファイル: LogEntryTest.php プロジェクト: Webiny/AnalyticsDb
 public function testSetGetRef()
 {
     $le = new LogEntry('page');
     $le->setRef('one');
     $this->assertSame('one', $le->getRef());
     $le->setRef(100);
     $this->assertSame(100, $le->getRef());
 }
コード例 #2
0
ファイル: AnalyticsDb.php プロジェクト: Webiny/AnalyticsDb
 /**
  * Add a log to the buffer.
  * Note: the data is not saved until you call the save method.
  *
  * @param string $entity Entity name.
  * @param int    $ref
  * @param int    $increment
  *
  * @return LogEntry
  * @throws AnalyticsDbException
  */
 public function log($entity, $ref = 0, $increment = 1)
 {
     if (!preg_match('/^([A-z0-9\\/\\-\\_]+)$/', $entity)) {
         throw new AnalyticsDbException('Entity name can only contain ([A-z0-9\\/\\-]).');
     }
     if (!preg_match('/^([A-z0-9\\/\\-\\_]+)$/', $ref)) {
         throw new AnalyticsDbException('Entity referrer can only contain ([A-z0-9\\/\\-]).');
     }
     $entry = new LogEntry($entity);
     $entry->setRef($ref);
     $entry->setIncrement($increment);
     $this->logBuffer->addEntry($entry);
     return $entry;
 }