<commit_before><?php
namespace Concrete\Package\CommunityStore\Src\CommunityStore\Product\ProductVariation;

use Concrete\Core\File\File;
use Doctrine\ORM\Mapping as ORM;
use Concrete\Core\Support\Facade\Application;
use Doctrine\Common\Collections\ArrayCollection;
use Concrete\Core\Support\Facade\DatabaseORM as dbORM;
use Concrete\Package\CommunityStore\Src\CommunityStore\Utilities\Price;
use Concrete\Package\CommunityStore\Src\CommunityStore\Product\Product;
use Concrete\Package\CommunityStore\Src\CommunityStore\Product\ProductOption\ProductOptionItem;
use Concrete\Package\CommunityStore\Src\CommunityStore\Product\ProductVariation\ProductVariationOptionItem;

/**
 * @ORM\Entity
 * @ORM\Table(name="CommunityStoreProductVariations")
 */
class ProductVariation
{
    /**
     * @ORM\Id @ORM\Column(type="integer")
     * @ORM\GeneratedValue
     */
    protected $pvID;

    /**
     * @ORM\ManyToOne(targetEntity="Concrete\Package\CommunityStore\Src\CommunityStore\Product\Product", inversedBy="variations", cascade={"persist"})
     * @ORM\JoinColumn(name="pID", referencedColumnName="pID", onDelete="CASCADE")
     */
    protected $product;

    /**
     * @ORM\Column(type="decimal", precision=10, scale=2, nullable=true)
     */
    protected $pvPrice;

    /**
     * @ORM\Column(type="decimal", precision=10, scale=2, nullable=true)
     */
    protected $pvWholesalePrice;

    /**
     * @ORM\Column(type="string",nullable=true)
     */
    protected $pvSKU;

    /**
     * @ORM\Column(type="string",nullable=true)
     */
    protected $pvBarcode;

    /**
     * @ORM\Column(type="decimal", precision=10, scale=2, nullable=true)
     */
    protected $pvSalePrice;

    /**
     * @ORM\Column(type="integer",nullable=true)
     */
    protected $pvfID;

    /**
     * @ORM\Column(type="decimal", precision=12, scale=4)
     */
    protected $pvQty;

    /**
     * @ORM\Column(type="boolean",nullable=true)
     */
    protected $pvQtyUnlim;

    /**
     * @ORM\Column(type="decimal", precision=10, scale=2,nullable=true)
     */
    protected $pvWidth;

    /**
     * @ORM\Column(type="decimal", precision=10, scale=2,nullable=true)
     */
    protected $pvHeight;

    /**
     * @ORM\Column(type="decimal", precision=10, scale=2,nullable=true)
     */
    protected $pvLength;

    /**
     * @ORM\Column(type="decimal", precision=10, scale=2,nullable=true)
     */
    protected $pvWeight;

    /**
     * @ORM\Column(type="integer",nullable=true)
     */
    protected $pvNumberItems;

    /**
     * @ORM\Column(type="text",nullable=true)
     */
    protected $pvPackageData;

    /**
     * @ORM\Column(type="integer")
     */
    protected $pvSort;

    /**
     * @ORM\OneToMany(targetEntity="Concrete\Package\CommunityStore\Src\CommunityStore\Product\ProductVariation\ProductVariationOptionItem", mappedBy="variation", cascade={"persist"}))
     */
    protected $options;


    /**
     * @ORM\return mixed
     */
    public function getVariationFID()
    {
        return $this->pvfID;
    }

    /**
     * @ORM\param mixed $pvfID
     */
    public function setVariationFID($pvfID)
    {
        $this->pvfID = $pvfID;
    }

    public function getVariationImageID()
    {
        return $this->pvfID;
    }

    public function getVariationImageObj()
    {
        if ($this->pvfID) {
            $fileObj = File::getByID($this->pvfID);

            return $fileObj;
        }
    }

    public function __construct()
    {
        $this->options = new ArrayCollection();
    }

    public function getOptions()
    {
        return $this->options;
    }

    public function getOptionItemIDs()
    {
        $options = $this->getOptions();

        $optionids = [];

        foreach ($options as $opt) {
            $optionids[] = $opt->getOptionItem()->getID();
        }

        sort($optionids);

        return $optionids;
    }

    /**
     * @ORM\return mixed
     */
    public function getID()
    {
        return $this->pvID;
    }

    /**
     * @ORM\return mixed
     */
    public function getProductID()
    {
        return $this->pID;
    }

    public function getProduct() {
        return $this->product;
    }

    public function setProduct($product) {
        $this->product = $product;
    }
<commit_msg>Check for whether option item is valid<commit_after><?php
namespace Concrete\Package\CommunityStore\Src\CommunityStore\Product\ProductVariation;

use Concrete\Core\File\File;
use Doctrine\ORM\Mapping as ORM;
use Concrete\Core\Support\Facade\Application;
use Doctrine\Common\Collections\ArrayCollection;
use Concrete\Core\Support\Facade\DatabaseORM as dbORM;
use Concrete\Package\CommunityStore\Src\CommunityStore\Utilities\Price;
use Concrete\Package\CommunityStore\Src\CommunityStore\Product\Product;
use Concrete\Package\CommunityStore\Src\CommunityStore\Product\ProductOption\ProductOptionItem;
use Concrete\Package\CommunityStore\Src\CommunityStore\Product\ProductVariation\ProductVariationOptionItem;

/**
 * @ORM\Entity
 * @ORM\Table(name="CommunityStoreProductVariations")
 */
class ProductVariation
{
    /**
     * @ORM\Id @ORM\Column(type="integer")
     * @ORM\GeneratedValue
     */
    protected $pvID;

    /**
     * @ORM\ManyToOne(targetEntity="Concrete\Package\CommunityStore\Src\CommunityStore\Product\Product", inversedBy="variations", cascade={"persist"})
     * @ORM\JoinColumn(name="pID", referencedColumnName="pID", onDelete="CASCADE")
     */
    protected $product;

    /**
     * @ORM\Column(type="decimal", precision=10, scale=2, nullable=true)
     */
    protected $pvPrice;

    /**
     * @ORM\Column(type="decimal", precision=10, scale=2, nullable=true)
     */
    protected $pvWholesalePrice;

    /**
     * @ORM\Column(type="string",nullable=true)
     */
    protected $pvSKU;

    /**
     * @ORM\Column(type="string",nullable=true)
     */
    protected $pvBarcode;

    /**
     * @ORM\Column(type="decimal", precision=10, scale=2, nullable=true)
     */
    protected $pvSalePrice;

    /**
     * @ORM\Column(type="integer",nullable=true)
     */
    protected $pvfID;

    /**
     * @ORM\Column(type="decimal", precision=12, scale=4)
     */
    protected $pvQty;

    /**
     * @ORM\Column(type="boolean",nullable=true)
     */
    protected $pvQtyUnlim;

    /**
     * @ORM\Column(type="decimal", precision=10, scale=2,nullable=true)
     */
    protected $pvWidth;

    /**
     * @ORM\Column(type="decimal", precision=10, scale=2,nullable=true)
     */
    protected $pvHeight;

    /**
     * @ORM\Column(type="decimal", precision=10, scale=2,nullable=true)
     */
    protected $pvLength;

    /**
     * @ORM\Column(type="decimal", precision=10, scale=2,nullable=true)
     */
    protected $pvWeight;

    /**
     * @ORM\Column(type="integer",nullable=true)
     */
    protected $pvNumberItems;

    /**
     * @ORM\Column(type="text",nullable=true)
     */
    protected $pvPackageData;

    /**
     * @ORM\Column(type="integer")
     */
    protected $pvSort;

    /**
     * @ORM\OneToMany(targetEntity="Concrete\Package\CommunityStore\Src\CommunityStore\Product\ProductVariation\ProductVariationOptionItem", mappedBy="variation", cascade={"persist"}))
     */
    protected $options;


    /**
     * @ORM\return mixed
     */
    public function getVariationFID()
    {
        return $this->pvfID;
    }

    /**
     * @ORM\param mixed $pvfID
     */
    public function setVariationFID($pvfID)
    {
        $this->pvfID = $pvfID;
    }

    public function getVariationImageID()
    {
        return $this->pvfID;
    }

    public function getVariationImageObj()
    {
        if ($this->pvfID) {
            $fileObj = File::getByID($this->pvfID);

            return $fileObj;
        }
    }

    public function __construct()
    {
        $this->options = new ArrayCollection();
    }

    public function getOptions()
    {
        return $this->options;
    }

    public function getOptionItemIDs()
    {
        $options = $this->getOptions();

        $optionids = [];

        foreach ($options as $opt) {
            $optItem = $opt->getOptionItem();

            if ($optItem) {
                $optionids[] = $optItem->getID();
            }
        }

        sort($optionids);

        return $optionids;
    }

    /**
     * @ORM\return mixed
     */
    public function getID()
    {
        return $this->pvID;
    }

    /**
     * @ORM\return mixed
     */
    public function getProductID()
    {
        return $this->pID;
    }

    public function getProduct() {
        return $this->product;
    }

    public function setProduct($product) {
        $this->product = $product;
    }

{'fraction_non_alphanumeric': 0.14962449451184287, 'fraction_numerical': 0.005545927209705373, 'mean_word_length': 2.61419624217119, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 31, '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': '4043887', 'n_tokens_mistral': 2820, 'n_tokens_neox': 2713, 'n_words': 390}