@@ -46,8 +46,8 @@ public function setUp()
4646 public function it_can_create_a_copy_with_a_new_item_for_a_specific_key ()
4747 {
4848 $ collection = (new FooCollection ())
49- ->with ( $ this ->foo1 , ' foo1 ' )
50- ->with ( $ this ->foo2 , ' foo2 ' );
49+ ->withKey ( ' foo1 ' , $ this ->foo1 )
50+ ->withKey ( ' foo2 ' , $ this ->foo2 );
5151
5252 $ expected = [
5353 'foo1 ' => $ this ->foo1 ,
@@ -110,7 +110,7 @@ public function it_guards_the_object_type_of_items_when_initializing_from_array(
110110 public function it_allows_sub_classes_when_guarding_the_object_type_of_new_items ()
111111 {
112112 $ collection = (new FooCollection ())
113- ->with ( $ this ->fooExtended , ' fooExtended ' );
113+ ->withKey ( ' fooExtended ' , $ this ->fooExtended );
114114
115115 $ expected = [
116116 'fooExtended ' => $ this ->fooExtended ,
@@ -143,7 +143,7 @@ public function it_can_remove_an_item()
143143 public function it_throws_an_exception_when_removing_an_unknown_item ()
144144 {
145145 $ collection = (new FooCollection ())
146- ->with ( $ this ->foo1 , ' foo1 ' );
146+ ->withKey ( ' foo1 ' , $ this ->foo1 );
147147
148148 $ this ->setExpectedException (CollectionItemNotFoundException::class);
149149 $ collection ->without ($ this ->foo2 );
@@ -155,8 +155,8 @@ public function it_throws_an_exception_when_removing_an_unknown_item()
155155 public function it_can_remove_an_item_by_key ()
156156 {
157157 $ collection = (new FooCollection ())
158- ->with ( $ this ->foo1 , ' foo1 ' )
159- ->with ( $ this ->foo2 , ' foo2 ' );
158+ ->withKey ( ' foo1 ' , $ this ->foo1 )
159+ ->withKey ( ' foo2 ' , $ this ->foo2 );
160160
161161 $ collection = $ collection ->withoutKey ('foo1 ' );
162162
@@ -173,8 +173,8 @@ public function it_can_remove_an_item_by_key()
173173 public function it_throws_an_exception_when_removing_by_unknown_key ()
174174 {
175175 $ collection = (new FooCollection ())
176- ->with ( $ this ->foo1 , ' foo1 ' )
177- ->with ( $ this ->foo2 , ' foo2 ' );
176+ ->withKey ( ' foo1 ' , $ this ->foo1 )
177+ ->withKey ( ' foo2 ' , $ this ->foo2 );
178178
179179 $ this ->setExpectedException (CollectionKeyNotFoundException::class);
180180 $ collection ->withoutKey ('foo3 ' );
@@ -186,8 +186,8 @@ public function it_throws_an_exception_when_removing_by_unknown_key()
186186 public function it_can_return_an_item_by_key ()
187187 {
188188 $ collection = (new FooCollection ())
189- ->with ( $ this ->foo1 , ' foo1 ' )
190- ->with ( $ this ->foo2 , ' foo2 ' );
189+ ->withKey ( ' foo1 ' , $ this ->foo1 )
190+ ->withKey ( ' foo2 ' , $ this ->foo2 );
191191
192192 $ this ->assertEquals (
193193 $ this ->foo1 ,
@@ -206,7 +206,7 @@ public function it_can_return_an_item_by_key()
206206 public function it_throws_an_exception_when_looking_for_an_item_with_an_unknown_key ()
207207 {
208208 $ collection = (new FooCollection ())
209- ->with ( $ this ->foo1 , ' foo1 ' );
209+ ->withKey ( ' foo1 ' , $ this ->foo1 );
210210
211211 $ this ->setExpectedException (CollectionKeyNotFoundException::class);
212212 $ collection ->getByKey ('foo2 ' );
@@ -218,8 +218,8 @@ public function it_throws_an_exception_when_looking_for_an_item_with_an_unknown_
218218 public function it_can_return_the_key_for_an_item ()
219219 {
220220 $ collection = (new FooCollection ())
221- ->with ( $ this ->foo1 , ' foo1 ' )
222- ->with ( $ this ->foo2 , ' foo2 ' );
221+ ->withKey ( ' foo1 ' , $ this ->foo1 )
222+ ->withKey ( ' foo2 ' , $ this ->foo2 );
223223
224224 $ this ->assertEquals (
225225 'foo1 ' ,
@@ -238,7 +238,7 @@ public function it_can_return_the_key_for_an_item()
238238 public function it_throws_an_exception_when_looking_for_the_key_of_an_unknown_item ()
239239 {
240240 $ collection = (new FooCollection ())
241- ->with ( $ this ->foo1 , ' foo1 ' );
241+ ->withKey ( ' foo1 ' , $ this ->foo1 );
242242
243243 $ this ->setExpectedException (CollectionItemNotFoundException::class);
244244 $ collection ->getKeyFor ($ this ->foo2 );
@@ -250,8 +250,8 @@ public function it_throws_an_exception_when_looking_for_the_key_of_an_unknown_it
250250 public function it_can_return_a_list_of_keys ()
251251 {
252252 $ collection = (new FooCollection ())
253- ->with ( $ this ->foo1 , ' foo1 ' )
254- ->with ( $ this ->foo2 , ' foo2 ' );
253+ ->withKey ( ' foo1 ' , $ this ->foo1 )
254+ ->withKey ( ' foo2 ' , $ this ->foo2 );
255255
256256 $ expected = [
257257 'foo1 ' ,
@@ -297,9 +297,9 @@ public function it_can_be_converted_from_and_to_an_array()
297297 public function it_can_be_looped_over_like_an_array ()
298298 {
299299 $ collection = (new FooCollection ())
300- ->with ( $ this ->foo1 , ' foo1 ' )
301- ->with ( $ this ->foo2 , ' foo2 ' )
302- ->with ( $ this ->fooExtended , ' fooExtended ' );
300+ ->withKey ( ' foo1 ' , $ this ->foo1 )
301+ ->withKey ( ' foo2 ' , $ this ->foo2 )
302+ ->withKey ( ' fooExtended ' , $ this ->fooExtended );
303303
304304 $ expected = [
305305 'foo1 ' => $ this ->foo1 ,
0 commit comments