DungPit::offer()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of the Veslo project <https://github.com/symfony-doge/veslo>.
5
 *
6
 * (C) 2019 Pavel Petrov <[email protected]>.
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 * @license https://opensource.org/licenses/GPL-3.0 GPL-3.0
12
 */
13
14
declare(strict_types=1);
15
16
namespace Veslo\AnthillBundle\Vacancy;
17
18
use Veslo\AppBundle\Workflow\Vacancy\PitInterface;
19
use Veslo\AppBundle\Workflow\Vacancy\Research\Conveyor;
20
21
/**
22
 * This pit is full of dung (vacancies, especially for PHP engineers)
23
 */
24
class DungPit implements PitInterface
25
{
26
    /**
27
     * Manages data exchange between workers using workflow
28
     *
29
     * @var Conveyor
30
     */
31
    private $conveyor;
32
33
    /**
34
     * Dto class
35
     *
36
     * @var string
37
     */
38
    private $dtoClass;
39
40
    /**
41
     * DungPit constructor.
42
     *
43
     * @param Conveyor $conveyor Manages data exchange between workers using workflow
44
     * @param string   $dtoClass
45
     */
46
    public function __construct(Conveyor $conveyor, string $dtoClass)
47
    {
48
        $this->conveyor = $conveyor;
49
        $this->dtoClass = $dtoClass;
50
    }
51
52
    /**
53
     * {@inheritdoc}
54
     */
55
    public function poll(): ?object
56
    {
57
        return $this->conveyor->receive($this->dtoClass);
58
    }
59
60
    /**
61
     * {@inheritdoc}
62
     */
63
    public function offer(object $dto): bool
64
    {
65
        $this->conveyor->send($dto);
66
67
        // No overflow checks.
68
        return true;
69
    }
70
}
71