<commit_before><?php
/*
 * WellCommerce Open-Source E-Commerce Platform
 *
 * This file is part of the WellCommerce package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information,
 * please view the LICENSE file that was distributed with this source code.
 */
namespace WellCommerce\Bundle\AppBundle\Entity;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Knp\DoctrineBehaviors\Model\Blameable\Blameable;
use Knp\DoctrineBehaviors\Model\Timestampable\Timestampable;
use Symfony\Component\Security\Core\Encoder\EncoderAwareInterface;
use Symfony\Component\Security\Core\User\EquatableInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use WellCommerce\Bundle\CoreBundle\Doctrine\Behaviours\Identifiable;
use WellCommerce\Bundle\CoreBundle\Entity\EntityInterface;
use WellCommerce\Bundle\OrderBundle\Entity\Order;

/**
 * Class Client
 *
 * @author  <NAME> <<EMAIL>>
 */
class Client implements EntityInterface, \Serializable, UserInterface, EquatableInterface, EncoderAwareInterface
{
    const ROLE_CLIENT = 'ROLE_CLIENT';
    
    use Identifiable;
    use Timestampable;
    use Blameable;
    use ShopAwareTrait;
    
    /**
     * @var Collection
     */
    protected $orders;
    
    /**
     * @var ClientDetails
     */
    protected $clientDetails;
    
    /**
     * @var ClientContactDetails
     */
    protected $contactDetails;
    
    /**
     * @var ClientBillingAddress
     */
    protected $billingAddress;
    
    /**
     * @var ClientShippingAddress
     */
    protected $shippingAddress;
    
    /**
     * @var ClientGroup
     */
    protected $clientGroup;
    
    public function __construct()
    {
        $this->orders          = new ArrayCollection();
        $this->clientDetails   = new ClientDetails();
        $this->contactDetails  = new ClientContactDetails();
        $this->billingAddress  = new ClientBillingAddress();
        $this->shippingAddress = new ClientShippingAddress();
    }
    
    public function getPassword()
    {
        return $this->clientDetails->getPassword();
    }
    
    public function getSalt()
    {
        return null;
    }
    
    public function getUsername()
    {
        return $this->clientDetails->getUsername();
    }
    
    public function eraseCredentials()
    {
    }
    
    public function getRoles()
    {
        return [
            self::ROLE_CLIENT,
        ];
    }
    
    public function serialize()
    {
        return serialize([$this->id, $this->getUsername(), $this->getPassword()]);
    }
    
    public function unserialize($serialized)
    {
        list($this->id, $username, $password) = unserialize($serialized);
        $this->clientDetails->setUsername($username);
        $this->clientDetails->setPassword($password);
    }
    
    public function isEqualTo(UserInterface $user)
    {
        if (!$user instanceof Client) {
            return false;
        }
        
        if ($this->getPassword() !== $user->getPassword()) {
            return false;
        }<commit_msg>Fixed missing ClientDetails in unserialize method<commit_after><?php
/*
 * WellCommerce Open-Source E-Commerce Platform
 *
 * This file is part of the WellCommerce package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information,
 * please view the LICENSE file that was distributed with this source code.
 */
namespace WellCommerce\Bundle\AppBundle\Entity;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Knp\DoctrineBehaviors\Model\Blameable\Blameable;
use Knp\DoctrineBehaviors\Model\Timestampable\Timestampable;
use Symfony\Component\Security\Core\Encoder\EncoderAwareInterface;
use Symfony\Component\Security\Core\User\EquatableInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use WellCommerce\Bundle\CoreBundle\Doctrine\Behaviours\Identifiable;
use WellCommerce\Bundle\CoreBundle\Entity\EntityInterface;
use WellCommerce\Bundle\OrderBundle\Entity\Order;

/**
 * Class Client
 *
 * @author  <NAME> <<EMAIL>>
 */
class Client implements EntityInterface, \Serializable, UserInterface, EquatableInterface, EncoderAwareInterface
{
    const ROLE_CLIENT = 'ROLE_CLIENT';
    
    use Identifiable;
    use Timestampable;
    use Blameable;
    use ShopAwareTrait;
    
    /**
     * @var Collection
     */
    protected $orders;
    
    /**
     * @var ClientDetails
     */
    protected $clientDetails;
    
    /**
     * @var ClientContactDetails
     */
    protected $contactDetails;
    
    /**
     * @var ClientBillingAddress
     */
    protected $billingAddress;
    
    /**
     * @var ClientShippingAddress
     */
    protected $shippingAddress;
    
    /**
     * @var ClientGroup
     */
    protected $clientGroup;
    
    public function __construct()
    {
        $this->orders          = new ArrayCollection();
        $this->clientDetails   = new ClientDetails();
        $this->contactDetails  = new ClientContactDetails();
        $this->billingAddress  = new ClientBillingAddress();
        $this->shippingAddress = new ClientShippingAddress();
    }
    
    public function getPassword()
    {
        return $this->clientDetails->getPassword();
    }
    
    public function getSalt()
    {
        return null;
    }
    
    public function getUsername()
    {
        return $this->clientDetails->getUsername();
    }
    
    public function eraseCredentials()
    {
    }
    
    public function getRoles()
    {
        return [
            self::ROLE_CLIENT,
        ];
    }
    
    public function serialize()
    {
        return serialize([$this->id, $this->getUsername(), $this->getPassword()]);
    }
    
    public function unserialize($serialized)
    {
        list($this->id, $username, $password) = unserialize($serialized);
        if (!$this->clientDetails instanceof ClientDetails) {
            $this->clientDetails = new ClientDetails();
        }
        $this->clientDetails->setUsername($username);
        $this->clientDetails->setPassword($password);
    }
    
    public function isEqualTo(UserInterface $user)
    {
        if (!$user instanceof Client) {
            return false;
        }
        
        if ($this->getPassword() !== $user->getPassword()) {
            return false;
        }
{'fraction_non_alphanumeric': 0.10969468051621026, 'fraction_numerical': 0.0, 'mean_word_length': 2.6149032992036405, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 55, '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': '930118', 'n_tokens_mistral': 1768, 'n_tokens_neox': 1777, 'n_words': 366}