1<?php
2/**
3 * Copyright since 2007 PrestaShop SA and Contributors
4 * PrestaShop is an International Registered Trademark & Property of PrestaShop SA
5 *
6 * NOTICE OF LICENSE
7 *
8 * This source file is subject to the Open Software License (OSL 3.0)
9 * that is bundled with this package in the file LICENSE.md.
10 * It is also available through the world-wide-web at this URL:
11 * https://opensource.org/licenses/OSL-3.0
12 * If you did not receive a copy of the license and are unable to
13 * obtain it through the world-wide-web, please send an email
14 * to license@prestashop.com so we can send you a copy immediately.
15 *
16 * DISCLAIMER
17 *
18 * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
19 * versions in the future. If you wish to customize PrestaShop for your
20 * needs please refer to https://devdocs.prestashop.com/ for more information.
21 *
22 * @author    PrestaShop SA and Contributors <contact@prestashop.com>
23 * @copyright Since 2007 PrestaShop SA and Contributors
24 * @license   https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
25 */
26use PrestaShop\PrestaShop\Core\Session\SessionInterface;
27
28class CustomerSessionCore extends ObjectModel implements SessionInterface
29{
30    public $id;
31
32    /** @var Id Customer */
33    public $id_customer;
34
35    /** @var string Token */
36    public $token;
37
38    /**
39     * @see ObjectModel::$definition
40     */
41    public static $definition = [
42        'table' => 'customer_session',
43        'primary' => 'id_customer_session',
44        'fields' => [
45            'id_customer' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
46            'token' => ['type' => self::TYPE_STRING, 'validate' => 'isSha1', 'size' => 40, 'copy_post' => false],
47        ],
48    ];
49
50    /**
51     * {@inheritdoc}
52     */
53    public function getId()
54    {
55        return $this->id;
56    }
57
58    /**
59     * {@inheritdoc}
60     */
61    public function setUserId($idCustomer)
62    {
63        $this->id_customer = (int) $idCustomer;
64    }
65
66    /**
67     * {@inheritdoc}
68     */
69    public function getUserId()
70    {
71        return (int) $this->id_customer;
72    }
73
74    /**
75     * {@inheritdoc}
76     */
77    public function setToken($token)
78    {
79        $this->token = (string) $token;
80    }
81
82    /**
83     * {@inheritdoc}
84     */
85    public function getToken()
86    {
87        return $this->token;
88    }
89}
90