• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lmc-eu / matej-client-php / 7469814138

20 Oct 2022 11:42AM UTC coverage: 100.0%. Remained the same
7469814138

push

github

OndraM
Block fixup commits from accidental merge

746 of 746 relevant lines covered (100.0%)

27.9 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/Model/Command/ItemSorting.php
1
<?php declare(strict_types=1);
2

3
namespace Lmc\Matej\Model\Command;
4

5
use Lmc\Matej\Model\Assertion;
6

7
/**
8
 * Sorting items is a way how to use Matej to deliver personalized experience to users.
9
 * It allows to sort given list of items according to the user preference.
10
 */
11
class ItemSorting extends AbstractCommand implements UserAwareInterface
12
{
13
    /** @var string */
14
    private $userId;
15
    /** @var string[] */
16
    private $itemIds = [];
17
    /** @var string|null */
18
    private $modelName;
19

20
    private function __construct(string $userId, array $itemIds)
21
    {
22
        $this->setUserId($userId);
6✔
23
        $this->setItemIds($itemIds);
6✔
24
    }
3✔
25

26
    /**
27
     * Sort given item ids for user-based recommendations.
28
     *
29
     * @return static
30
     */
31
    public static function create(string $userId, array $itemIds): self
32
    {
33
        return new static($userId, $itemIds);
6✔
34
    }
35

36
    /**
37
     * Set A/B model name
38
     *
39
     * @return $this
40
     */
41
    public function setModelName(string $modelName): self
42
    {
43
        Assertion::typeIdentifier($modelName);
6✔
44

45
        $this->modelName = $modelName;
6✔
46

47
        return $this;
6✔
48
    }
49

50
    public function getUserId(): string
51
    {
52
        return $this->userId;
6✔
53
    }
54

55
    protected function setUserId(string $userId): void
56
    {
57
        Assertion::typeIdentifier($userId);
6✔
58

59
        $this->userId = $userId;
6✔
60
    }
3✔
61

62
    protected function setItemIds(array $itemIds): void
63
    {
64
        Assertion::allTypeIdentifier($itemIds);
6✔
65

66
        $this->itemIds = $itemIds;
6✔
67
    }
3✔
68

69
    protected function getCommandType(): string
70
    {
71
        return 'sorting';
6✔
72
    }
73

74
    protected function getCommandParameters(): array
75
    {
76
        $parameters = [
3✔
77
            'user_id' => $this->userId,
6✔
78
            'item_ids' => $this->itemIds,
6✔
79
        ];
3✔
80

81
        if ($this->modelName !== null) {
6✔
82
            $parameters['model_name'] = $this->modelName;
6✔
83
        }
84

85
        return $parameters;
6✔
86
    }
87
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc