<commit_before><?php
/**
 * @author @ct-jensschulze <<EMAIL>>
 */

namespace Commercetools\Core\Model\ProductType;

use Commercetools\Core\Model\Common\Collection;

/**
 * @package Commercetools\Core\Model\ProductType
 *
 * @method ProductType current()
 * @method ProductTypeCollection add(ProductType $element)
 * @method ProductType getAt($offset)
 */
class ProductTypeCollection extends Collection
{
    protected $type = '\Commercetools\Core\Model\ProductType\ProductType';
}<commit_msg>feat(ProductType): add getByName and getById to ProductTypeCollection<commit_after><?php
/**
 * @author @ct-jensschulze <<EMAIL>>
 */

namespace Commercetools\Core\Model\ProductType;

use Commercetools\Core\Model\Common\Collection;

/**
 * @package Commercetools\Core\Model\ProductType
 *
 * @method ProductType current()
 * @method ProductTypeCollection add(ProductType $element)
 * @method ProductType getAt($offset)
 */
class ProductTypeCollection extends Collection
{
    const ID = 'id';
    const NAME = 'name';
    protected $type = '\Commercetools\Core\Model\ProductType\ProductType';

    protected function indexRow($offset, $row)
    {
        if ($row instanceof ProductType) {
            $id = $row->getId();
            $name = $row->getName();
        } else {
            $id = isset($row[static::ID]) ? $row[static::ID] : null;
            $name = isset($row[static::NAME]) ? $row[static::NAME] : null;
        }
        $this->addToIndex(static::ID, $offset, $id);
        $this->addToIndex(static::NAME, $offset, $name);
    }

    /**
     * @param $id
     * @return ProductType
     */
    public function getById($id)
    {
        return $this->getBy(static::ID, $id);
    }

    /**
     * @param $name
     * @return ProductType
     */
    public function getByName($name)
    {
        return $this->getBy(static::NAME, $name);
    }
}
{'fraction_non_alphanumeric': 0.1492456896551724, 'fraction_numerical': 0.0, 'mean_word_length': 3.268965517241379, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, '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': '2133125', 'n_tokens_mistral': 583, 'n_tokens_neox': 584, 'n_words': 113}