<commit_before><?php

// id	title	description	google product category	product type	link	image link	condition	availability	price	sale price	sale price effective date	gtin	brand	mpn	item group id	gender	age group	color	size	shipping	shipping weight

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Repositories\Product\ProductRepository;
use Illuminate\Cache\Repository as CacheRepository;
use Carbon\Carbon;

class ProductsController extends Controller
{
    protected $products;
    protected $cache;
    protected $keys;
    protected $consts;

    public function __construct (ProductRepository $products, CacheRepository $cache)
    {
      $this->products = $products;
      $this->cache = $cache;
      $this->keys = collect(['id', 'title', 'description', 'link', 'image_link', 'availability', 'price', 'mpn', 'condition', 'brand', 'color', 'size',]);
    }

    public function feed()
    {
        $consts = [
      'site_url'  => config('app.url'),
      'shop_name' => config('shop.name'),
      'currency'  => config('shop.currency'),
    ];


        $data = $this->cache->remember('product-feed-text', Carbon::now()->addHours(23), function () use ($consts){
          $products = $this->products->all(['media', 'product_categories', 'attribute_properties']);

          if (!$products->count()) {
              return $this->keys->implode("\t");
          }

          $data = $products
            ->filter(function ($p) {
                return $p->inStock();
            })
            ->map(function ($p) use ($consts) {
              $image = $p->media->count() ? $p->media->first()->getUrl('wide') : '';

              return $this->keys->combine([
                $p->sku,
                $p->name,
                $p->description,
                sprintf('%s%s', $consts['site_url'], $p->url),
                $image,
                'in stock',
                sprintf('%s %s', $p->price->asDecimal(), $consts['currency']),
                $p->sku,
                'new',
                $consts['shop_name'],
                $this->getProductProperties($p, 'colour'),
                $this->getProductProperties($p, 'size'),
              ]);
            });
            return $this->generateFeedText($data);<commit_msg>Apply fixes from StyleCI (#140)<commit_after><?php

// id	title	description	google product category	product type	link	image link	condition	availability	price	sale price	sale price effective date	gtin	brand	mpn	item group id	gender	age group	color	size	shipping	shipping weight

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Repositories\Product\ProductRepository;
use Carbon\Carbon;
use Illuminate\Cache\Repository as CacheRepository;

class ProductsController extends Controller
{
    protected $products;
    protected $cache;
    protected $keys;
    protected $consts;

    public function __construct(ProductRepository $products, CacheRepository $cache)
    {
        $this->products = $products;
        $this->cache = $cache;
        $this->keys = collect(['id', 'title', 'description', 'link', 'image_link', 'availability', 'price', 'mpn', 'condition', 'brand', 'color', 'size']);
    }

    public function feed()
    {
        $consts = [
      'site_url'  => config('app.url'),
      'shop_name' => config('shop.name'),
      'currency'  => config('shop.currency'),
    ];

        $data = $this->cache->remember('product-feed-text', Carbon::now()->addHours(23), function () use ($consts) {
            $products = $this->products->all(['media', 'product_categories', 'attribute_properties']);

            if (!$products->count()) {
                return $this->keys->implode("\t");
            }

            $data = $products
            ->filter(function ($p) {
                return $p->inStock();
            })
            ->map(function ($p) use ($consts) {
                $image = $p->media->count() ? $p->media->first()->getUrl('wide') : '';

                return $this->keys->combine([
                $p->sku,
                $p->name,
                $p->description,
                sprintf('%s%s', $consts['site_url'], $p->url),
                $image,
                'in stock',
                sprintf('%s %s', $p->price->asDecimal(), $consts['currency']),
                $p->sku,
                'new',
                $consts['shop_name'],
                $this->getProductProperties($p, 'colour'),
                $this->getProductProperties($p, 'size'),
              ]);
            });

            return $this->generateFeedText($data);
{'fraction_non_alphanumeric': 0.16031365715530385, 'fraction_numerical': 0.0015247222827270747, 'mean_word_length': 2.2590489709013486, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 71, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2266044', 'n_tokens_mistral': 1327, 'n_tokens_neox': 1274, 'n_words': 290}