• 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/AbstractUserRecommendation.php
1
<?php declare(strict_types=1);
2

3
namespace Lmc\Matej\Model\Command;
4

5
use Lmc\Matej\Model\Assertion;
6

7
/**
8
 * Deliver recommendations for given user.
9
 */
10
abstract class AbstractUserRecommendation extends AbstractRecommendation implements UserAwareInterface
11
{
12
    /** @var string */
13
    private $userId;
14
    /** @var float */
15
    private $rotationRate;
16
    /** @var int */
17
    private $rotationTime;
18
    /** @var bool */
19
    private $hardRotation;
20

21
    protected function __construct(string $userId, string $scenario)
22
    {
23
        parent::__construct($scenario);
63✔
24
        $this->setUserId($userId);
63✔
25
    }
26

27
    /**
28
     * Even with rotation rate 1.0 user could still obtain the same recommendations in some edge cases.
29
     * To prevent this, enable hard rotation - recommended items are then excluded until rotation time is expired.
30
     * By default hard rotation is not enabled.
31
     * @return $this
32
     */
33
    public function enableHardRotation(): self
34
    {
35
        $this->hardRotation = true;
14✔
36

37
        return $this;
14✔
38
    }
39

40
    /**
41
     * Get id of user requesting recommendation.
42
     */
43
    public function getUserId(): string
44
    {
45
        return $this->userId;
14✔
46
    }
47

48
    /**
49
     * Set how much should the item be penalized for being recommended again in the near future.
50
     *
51
     * @return $this
52
     */
53
    public function setRotationRate(float $rotationRate): self
54
    {
55
        Assertion::between($rotationRate, 0, 1);
14✔
56

57
        $this->rotationRate = $rotationRate;
14✔
58

59
        return $this;
14✔
60
    }
61

62
    /**
63
     * Specify for how long will the item's rotationRate be taken in account and so the item is penalized for
64
     * recommendations.
65
     *
66
     * @return $this
67
     */
68
    public function setRotationTime(int $rotationTime): self
69
    {
70
        Assertion::greaterOrEqualThan($rotationTime, 0);
21✔
71

72
        $this->rotationTime = $rotationTime;
21✔
73

74
        return $this;
21✔
75
    }
76

77
    protected function setUserId(string $userId): void
78
    {
79
        Assertion::typeIdentifier($userId);
63✔
80

81
        $this->userId = $userId;
63✔
82
    }
83

84
    protected function getCommandParameters(): array
85
    {
86
        $parameters = parent::getCommandParameters();
63✔
87

88
        $parameters['user_id'] = $this->userId;
63✔
89

90
        if ($this->rotationRate !== null) {
63✔
91
            $parameters['rotation_rate'] = $this->rotationRate;
14✔
92
        }
93

94
        if ($this->rotationTime !== null) {
63✔
95
            $parameters['rotation_time'] = $this->rotationTime;
21✔
96
        }
97

98
        if ($this->hardRotation !== null) {
63✔
99
            $parameters['hard_rotation'] = $this->hardRotation;
14✔
100
        }
101

102
        return $parameters;
63✔
103
    }
104
}
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