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

lmc-eu / matej-client-php / 7529439147

15 Jan 2024 01:18PM UTC coverage: 100.0%. Remained the same
7529439147

Pull #145

github

web-flow
Bump actions/checkout from 3 to 4

Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #145: Bump actions/checkout from 3 to 4

712 of 712 relevant lines covered (100.0%)

35.03 hits per line

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

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

3
namespace Lmc\Matej\Model\Command;
4

5
use ArrayObject;
6
use Lmc\Matej\Model\Assertion;
7

8
/**
9
 * Interaction command allows to send one interaction between a user and item.
10
 * When given user or item identifier is unknown, Matej will create such user or item respectively.
11
 */
12
class Interaction extends AbstractCommand implements UserAwareInterface
13
{
14
    private const DEFAULT_ITEM_ID_ALIAS = 'item_id';
15

16
    /** @var string */
17
    private $interactionType;
18
    /** @var string */
19
    private $userId;
20
    /** @var string */
21
    private $itemId;
22
    /** @var string */
23
    private $itemIdAlias;
24
    /** @var int */
25
    private $timestamp;
26
    /** @var ArrayObject */
27
    private $attributes;
28

29
    private function __construct(
30
        string $interactionType,
31
        string $userId,
32
        string $itemIdAlias,
33
        string $itemId,
34
        int $timestamp = null
35
    ) {
36
        $this->attributes = new ArrayObject();
84✔
37
        $this->setInteractionType($interactionType);
84✔
38
        $this->setUserId($userId);
77✔
39
        $this->setItemIdAlias($itemIdAlias);
70✔
40
        $this->setItemId($itemId);
63✔
41
        $this->setTimestamp($timestamp ?? time());
56✔
42
    }
43

44
    /**
45
     * Construct Interaction between user and item identified by ID.
46
     */
47
    public static function withItem(
48
        string $interactionType,
49
        string $userId,
50
        string $itemId,
51
        int $timestamp = null
52
    ): self {
53
        $interaction = new static(
63✔
54
            $interactionType,
63✔
55
            $userId,
63✔
56
            self::DEFAULT_ITEM_ID_ALIAS,
63✔
57
            $itemId,
63✔
58
            $timestamp
63✔
59
        );
63✔
60

61
        return $interaction;
35✔
62
    }
63

64
    /**
65
     * Construct Interaction between user and item identified by aliased ID.
66
     */
67
    public static function withAliasedItem(
68
        string $interactionType,
69
        string $userId,
70
        string $itemIdAlias,
71
        string $itemId,
72
        int $timestamp = null
73
    ): self {
74
        return new static(
21✔
75
            $interactionType,
21✔
76
            $userId,
21✔
77
            $itemIdAlias,
21✔
78
            $itemId,
21✔
79
            $timestamp
21✔
80
        );
21✔
81
    }
82

83
    public function getUserId(): string
84
    {
85
        return $this->userId;
28✔
86
    }
87

88
    public function getCommandType(): string
89
    {
90
        return 'interaction';
35✔
91
    }
92

93
    /**
94
     * Set all Interaction attributes. All previously set attributes are removed.
95
     */
96
    public function setAttributes(array $attributes): self
97
    {
98
        $this->attributes = new ArrayObject();
14✔
99
        foreach ($attributes as $name => $value) {
14✔
100
            $this->setAttribute($name, $value);
14✔
101
        }
102

103
        return $this;
7✔
104
    }
105

106
    /**
107
     * Set Interaction attribute and its value. If attribute with the same name
108
     * already exists, it's replaced.
109
     *
110
     * @param mixed $value
111
     */
112
    public function setAttribute(string $name, $value): self
113
    {
114
        Assertion::typeIdentifier($name);
21✔
115

116
        $this->attributes[$name] = $value;
14✔
117

118
        return $this;
14✔
119
    }
120

121
    public function getCommandParameters(): array
122
    {
123
        return [
35✔
124
            'interaction_type' => $this->interactionType,
35✔
125
            'user_id' => $this->userId,
35✔
126
            'timestamp' => $this->timestamp,
35✔
127
            'attributes' => $this->attributes,
35✔
128
            $this->itemIdAlias => $this->itemId,
35✔
129
        ];
35✔
130
    }
131

132
    protected function setInteractionType(string $interactionType): void
133
    {
134
        Assertion::typeIdentifier($interactionType);
84✔
135

136
        $this->interactionType = $interactionType;
77✔
137
    }
138

139
    protected function setUserId(string $userId): void
140
    {
141
        Assertion::typeIdentifier($userId);
77✔
142

143
        $this->userId = $userId;
70✔
144
    }
145

146
    protected function setItemId(string $itemId): void
147
    {
148
        Assertion::typeIdentifier($itemId);
63✔
149

150
        $this->itemId = $itemId;
56✔
151
    }
152

153
    protected function setItemIdAlias(string $itemIdAlias): void
154
    {
155
        Assertion::typeIdentifier($itemIdAlias);
70✔
156

157
        $this->itemIdAlias = $itemIdAlias;
63✔
158
    }
159

160
    protected function setTimestamp(int $timestamp): void
161
    {
162
        Assertion::greaterThan($timestamp, 0);
56✔
163

164
        $this->timestamp = $timestamp;
49✔
165
    }
166
}
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