Skip to content

Commit

Permalink
Added attribute first_contentful_paint_time (#2)
Browse files Browse the repository at this point in the history
* Add $firstContentfulPaintTime

* Add $firstContentfulPaintTime

* Added ability to send x-metrix-* parameters
  • Loading branch information
epifrin authored Feb 17, 2021
1 parent 94cefd8 commit 987471d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/GTMetrixClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,13 @@ public function getBrowser($id) {
* @param null|string $browser
* @param null|string $httpUser
* @param null|string $httpPassword
* @param array $xParams
*
* @return GTMetrixTest
* @throws GTMetrixConfigurationException
* @throws GTMetrixException
*/
public function startTest($url, $location = null, $browser = null, $httpUser = null, $httpPassword = null) {
public function startTest($url, $location = null, $browser = null, $httpUser = null, $httpPassword = null, array $xParams = []) {

$data = array();
$data['url'] = $url;
Expand All @@ -203,6 +204,9 @@ public function startTest($url, $location = null, $browser = null, $httpUser = n
if ($httpPassword) {
$data['login-pass'] = $httpPassword;
}
if ($xParams) {
$data = array_merge($data, $xParams);
}
$result = $this->apiCall('/test', $data);

$test = new GTMetrixTest();
Expand Down Expand Up @@ -242,6 +246,7 @@ public function getTestStatus($test) {
$test->setConnectDuration($testStatus['results']['connect_duration']);
$test->setBackendDuration($testStatus['results']['backend_duration']);
$test->setFirstPaintTime($testStatus['results']['first_paint_time']);
$test->setFirstContentfulPaintTime($testStatus['results']['first_contentful_paint_time']);
$test->setDomInteractiveTime($testStatus['results']['dom_interactive_time']);
$test->setDomContentLoadedTime($testStatus['results']['dom_content_loaded_time']);
$test->setDomContentLoadedDuration($testStatus['results']['dom_content_loaded_duration']);
Expand Down
19 changes: 19 additions & 0 deletions src/GTMetrixTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ class GTMetrixTest {
* @var int
*/
protected $firstPaintTime;

/**
* @var int
*/
protected $firstContentfulPaintTime;

/**
* @var int
Expand Down Expand Up @@ -359,6 +364,20 @@ public function setFirstPaintTime($firstPaintTime) {
$this->firstPaintTime = $firstPaintTime;
}

/**
* @return int
*/
public function getFirstContentfulPaintTime() {
return $this->firstContentfulPaintTime;
}

/**
* @param int $firstPaintTime
*/
public function setFirstContentfulPaintTime($firstContentfulPaintTime) {
$this->firstContentfulPaintTime = $firstContentfulPaintTime;
}

/**
* @return int
*/
Expand Down

0 comments on commit 987471d

Please sign in to comment.