Skip to content

Commit

Permalink
move functions Php\* to Php::*
Browse files Browse the repository at this point in the history
  • Loading branch information
kaluzki committed Nov 7, 2019
1 parent 597db94 commit 7dc5b74
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions src/Oxidio/Seo/DataLayer.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function __construct(FrontendController $ctrl, ArticleList ...$lists)
*/
public function getIterator(): Generator
{
if ($impressions = Php\traverse($this->impressions())) {
if ($impressions = Php::traverse($this->impressions())) {
/** @link https://developers.google.com/tag-manager/enhanced-ecommerce#product-impressions */
yield self::push(null, [
'currencyCode' => $this->getCurrencyCode(),
Expand All @@ -65,7 +65,7 @@ public function getIterator(): Generator
foreach ($this->cartActions() as $action => $products) {
yield self::push($action === 'add' ? 'addToCart' : 'removeFromCart' , [
'currencyCode' => $this->getCurrencyCode(),
$action => ['products' => Php\values($products)],
$action => ['products' => Php::values($products)],
]);
}

Expand Down Expand Up @@ -100,7 +100,7 @@ private function purchaseActions(): Generator
'shipping' => $order->getFieldData(T\ORDER::DELCOST),
'coupon' => implode(', ', $order->getVoucherNrList()),
],
'products' => Php\values(Product::map($order->getOrderArticles())),
'products' => Php::values(Product::map($order->getOrderArticles())),
]);
}

Expand Down Expand Up @@ -146,20 +146,20 @@ private function checkoutActions(): Generator

$actionField && yield self::push('checkout', [
'actionField' => $actionField,
'products' => Php\values($this->cartProducts()),
'products' => Php::values($this->cartProducts()),
]);
}

private static function push(...$args): array
{
return Php\traverse(self::event(...$args));
return Php::traverse(self::event(...$args));
}

private static function event(string $event = null, iterable $ecommerce = null): Generator
{
$ecommerce && $event && yield 'event' => $event;
yield 'ecommerce' => Php\traverse($ecommerce ?: [], static function($data) {
$data = is_iterable($data) ? Php\traverse($data) : $data;
yield 'ecommerce' => Php::traverse($ecommerce ?: [], static function ($data) {
$data = is_iterable($data) ? Php::traverse($data) : $data;
return $data ?: null;
});
}
Expand All @@ -179,7 +179,7 @@ private function impressions(): Generator
*/
private function cartActions(): array
{
return Php\traverse($this->cartChanges(), static function($product) {
return Php::traverse($this->cartChanges(), static function ($product) {
$group = $product->quantity > 0 ? 'add' : 'remove';
$product->quantity = abs($product->quantity);
return Php::mapGroup($group);
Expand Down
2 changes: 1 addition & 1 deletion src/Oxidio/Seo/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static function create(Base $item, array $data = []): self
*/
public static function map(iterable $items, array $data = []): array
{
return Php\map($items, static function($item) use($data) {
return Php::map($items, static function ($item) use ($data) {
return Php::mapValue($product = static::create($item, $data))->andKey($product->key);
})->sort()->traverse;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Oxidio/Seo/Snippet.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function __invoke(FrontendController $ctrl, Config $conf, LoggerInterface
try {
return sprintf(
$data::SNIPPET,
json_encode(Php\values($data(new DataLayer($ctrl, ...$lists))),JSON_PRETTY_PRINT),
json_encode(Php::values($data(new DataLayer($ctrl, ...$lists))),JSON_PRETTY_PRINT),
$id
);
} catch (Throwable $e) {
Expand Down

0 comments on commit 7dc5b74

Please sign in to comment.