Skip to content

Commit

Permalink
Add missing doc comments. Remove unused Event class.
Browse files Browse the repository at this point in the history
  • Loading branch information
message-dimke committed Aug 7, 2023
1 parent 9623fa1 commit 47a9b4d
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 36 deletions.
9 changes: 7 additions & 2 deletions src/Tracking.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
<?php
/**
* Pinterest tracking main class.
*
* @package Pinterest_For_WooCommerce/Classes/
* @version 1.0.0
*/

namespace Automattic\WooCommerce\Pinterest;

Expand All @@ -16,8 +22,7 @@
}

/**
* Class Tracker responsible for tracking events on the website and call corresponding trackers to send events to
* their systems.
* Class Tracker responsible for hooking into system events.
*/
class Tracking {

Expand Down
2 changes: 1 addition & 1 deletion src/Tracking/Conversions.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function track_event( string $event_name, Data $data ) {
$data = array(
'event_id' => $data->get_event_id(),
'custom_data' => array(
'category_name' => $data->getCategoryName(),
'category_name' => $data->getName(),
),
);
}
Expand Down
32 changes: 23 additions & 9 deletions src/Tracking/Data/Category.php
Original file line number Diff line number Diff line change
@@ -1,32 +1,46 @@
<?php
/**
* Pinterest tracking category data class.
*
* @package Pinterest_For_WooCommerce/Classes/
* @version 1.0.0
*/

namespace Automattic\WooCommerce\Pinterest\Tracking\Data;

use Automattic\WooCommerce\Pinterest\Tracking\Data;

/**
* Category data class to hold category name and id data.
*/
class Category extends Data {

private $product_category;
private $id;

private $category_name;
private $name;

public function __construct( $event_id, $product_category, $category_name ) {
/**
* @param string $event_id - A unique event id.
* @param string $id - Product category id.
* @param string $name - Product category name.
*/
public function __construct( $event_id, $id, $name ) {
parent::__construct( $event_id );
$this->product_category = $product_category;
$this->category_name = $category_name;
$this->id = $id;
$this->name = $name;
}

/**
* @return mixed
*/
public function getProductCategory() {
return $this->product_category;
public function getId() {
return $this->id;
}

/**
* @return mixed
*/
public function getCategoryName() {
return $this->category_name;
public function getName() {
return $this->name;
}
}
15 changes: 0 additions & 15 deletions src/Tracking/Data/Event.php

This file was deleted.

6 changes: 6 additions & 0 deletions src/Tracking/Data/None.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
<?php
/**
* Pinterest Tracking data class.
*
* @package Pinterest_For_WooCommerce/Classes/
* @version 1.0.0
*/

namespace Automattic\WooCommerce\Pinterest\Tracking\Data;

Expand Down
38 changes: 34 additions & 4 deletions src/Tracking/Data/Product.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
<?php
/**
* Pinterest Tracking data class.
*
* @package Pinterest_For_WooCommerce/Classes/
* @version 1.0.0
*/

namespace Automattic\WooCommerce\Pinterest\Tracking\Data;

use Automattic\WooCommerce\Pinterest\Tracking\Data;

/**
* Product data class. Hold product related data for event.
*
* @since x.x.x
*/
class Product extends Data {

private $id;
Expand All @@ -20,6 +31,16 @@ class Product extends Data {

private $quantity;

/**
* @param string $event_id - A unique event ID.
* @param string $id - Product ID.
* @param string $name - Product name.
* @param string $category - Product categories.
* @param string $brand - Product brand.
* @param string $price - Product price.
* @param string $currency - Product currency.
* @param string $quantity - Product quantity.
*/
public function __construct( $event_id, $id, $name, $category, $brand, $price, $currency, $quantity ) {
parent::__construct( $event_id );
$this->id = $id;
Expand All @@ -32,41 +53,50 @@ public function __construct( $event_id, $id, $name, $category, $brand, $price, $
}

/**
* @return mixed
* @return mixed Get Product ID.
*/
public function get_id() {
return $this->id;
}

/**
* @return mixed
* @return mixed Get Product name.
*/
public function get_name() {
return $this->name;
}

/**
* @return mixed Get Product category.
*/
public function get_category() {
return $this->category;
}

/**
* @return mixed Product brand.
*/
public function get_brand() {
return $this->brand;
}

/**
* @return mixed
* @return mixed Get Product price.
*/
public function get_price() {
return $this->price;
}

/**
* @return mixed
* @return mixed Get Product currency code.
*/
public function get_currency() {
return $this->currency;
}

/**
* @return mixed Get Product quantity.
*/
public function get_quantity() {
return $this->quantity;
}
Expand Down
10 changes: 10 additions & 0 deletions src/Tracking/Data/Search.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
<?php
/**
* Pinterest tracking search data class.
*
* @package Pinterest_For_WooCommerce/Classes/
* @version 1.0.0
*/

namespace Automattic\WooCommerce\Pinterest\Tracking\Data;

Expand All @@ -15,6 +21,10 @@ class Search extends Data {

private $search_query;

/**
* @param string $event_id - A unique event id.
* @param string $search_query - Search query.
*/
public function __construct( $event_id, $search_query ) {
parent::__construct( $event_id );
$this->search_query = $search_query;
Expand Down
7 changes: 6 additions & 1 deletion src/Tracking/Data/User.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
<?php
/**
* @package Pinterest_For_Woocommerce/API/Conversions
* Pinterest tracking user data class.
*
* @package Pinterest_For_WooCommerce/Classes/
* @version 1.0.0
*/
namespace Automattic\WooCommerce\Pinterest\Tracking\Data;

use Automattic\WooCommerce\Pinterest\Tracking\Data;

/**
* User data class holds user ip address and a user agent string.
*
* @link https://developers.pinterest.com/docs/conversions/best/#Required,%20recommended,%20and%20optional%20fields
*
* @since x.x.x
Expand Down
8 changes: 4 additions & 4 deletions src/Tracking/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ public function track_event( string $event_name, Data $data ) {
/** @var Category $data */
$data = array(
'event_id' => $data->get_event_id(),
'product_category' => $data->getProductCategory(),
'category_name' => $data->getCategoryName(),
'product_category' => $data->getId(),
'category_name' => $data->getName(),
);
}

Expand Down Expand Up @@ -259,7 +259,7 @@ public static function get_active_tag() {
/**
* Get the formatted warning message for the potential conflicting tags.
*
* @since 1.2.3
* @since x.x.x
*
* @return string The warning message.
*/
Expand All @@ -285,7 +285,7 @@ public static function get_third_party_tags_warning_message() {
/**
* Detect if there are other tags installed on the site.
*
* @since 1.2.3
* @since x.x.x
*
* @return array The list of installed tags.
*/
Expand Down

0 comments on commit 47a9b4d

Please sign in to comment.