Code Duplication    Length = 39-40 lines in 2 locations

tests/unit/Service/DelayServiceTest.php 1 location

@@ 92-131 (lines=40) @@
89
        return new DelayStrategyResolver($this->createStrategiesList(['test_strategy_key' => $strategy]), ['queue' => 'test_strategy_key']);
90
    }
91
92
    private function createStrategiesList(array $strategies)
93
    {
94
        return new class($strategies) implements \Iterator {
95
            /**
96
             * @var array
97
             */
98
            protected $strategies;
99
100
            public function __construct(array $strategies)
101
            {
102
                $this->strategies = $strategies;
103
            }
104
105
            public function current()
106
            {
107
                return current($this->strategies);
108
            }
109
110
            public function next()
111
            {
112
                return next($this->strategies);
113
            }
114
115
            public function key()
116
            {
117
                return key($this->strategies);
118
            }
119
120
            public function valid()
121
            {
122
                return key($this->strategies) !== null;
123
            }
124
125
            public function rewind()
126
            {
127
                return reset($this->strategies);
128
            }
129
130
        };
131
    }
132
}
133

tests/unit/Service/DelayStrategyResolverTest.php 1 location

@@ 64-102 (lines=39) @@
61
        return new DelayStrategyResolver($this->createStrategiesList($strategies), $strategiesByQueues);
62
    }
63
64
    private function createStrategiesList(array $strategies)
65
    {
66
        return new class($strategies) implements \Iterator {
67
            /**
68
             * @var array
69
             */
70
            protected $strategies;
71
72
            public function __construct(array $strategies)
73
            {
74
                $this->strategies = $strategies;
75
            }
76
77
            public function current()
78
            {
79
                return current($this->strategies);
80
            }
81
82
            public function next()
83
            {
84
                return next($this->strategies);
85
            }
86
87
            public function key()
88
            {
89
                return key($this->strategies);
90
            }
91
92
            public function valid()
93
            {
94
                return null !== key($this->strategies);
95
            }
96
97
            public function rewind()
98
            {
99
                return reset($this->strategies);
100
            }
101
        };
102
    }
103
}
104