File tree Expand file tree Collapse file tree 2 files changed +6
-8
lines changed Expand file tree Collapse file tree 2 files changed +6
-8
lines changed Original file line number Diff line number Diff line change 17
17
use ArrayAccess ;
18
18
use ArrayIterator ;
19
19
use BadMethodCallException ;
20
- use function get_class ;
21
- use InvalidArgumentException ;
22
20
use IteratorAggregate ;
23
21
use JsonSerializable ;
22
+ use OutOfBoundsException ;
24
23
use function sprintf ;
25
24
26
25
/**
@@ -73,7 +72,7 @@ final public function offsetGet($offset)
73
72
{
74
73
$ serialized = $ this ->toArray ();
75
74
if (!array_key_exists ($ offset , $ serialized )) {
76
- throw new InvalidArgumentException ("Offset: $ offset does not exists for class : " .static ::class);
75
+ throw new OutOfBoundsException ("Offset: \" $ offset\" does not exists in object of instance : " .static ::class);
77
76
}
78
77
79
78
return $ serialized [$ offset ];
@@ -85,14 +84,14 @@ final public function offsetGet($offset)
85
84
*/
86
85
final public function offsetSet ($ offset , $ value ): void
87
86
{
88
- throw new BadMethodCallException (sprintf ('%s is immutable ' , get_class ( $ this ) ));
87
+ throw new BadMethodCallException (sprintf ('%s is immutable ' , static ::class ));
89
88
}
90
89
91
90
/**
92
91
* @param TKey $offset
93
92
*/
94
93
final public function offsetUnset ($ offset ): void
95
94
{
96
- throw new BadMethodCallException (sprintf ('%s is immutable ' , get_class ( $ this ) ));
95
+ throw new BadMethodCallException (sprintf ('%s is immutable ' , static ::class ));
97
96
}
98
97
}
Original file line number Diff line number Diff line change 16
16
use function array_key_exists ;
17
17
use function array_key_last ;
18
18
use function array_slice ;
19
- use BadMethodCallException ;
20
19
use function is_int ;
21
20
use OutOfBoundsException ;
22
21
use function sort ;
@@ -72,7 +71,7 @@ public function last()
72
71
{
73
72
$ key = array_key_last ($ this ->sequence );
74
73
if (!is_int ($ key )) {
75
- throw new BadMethodCallException ('Cannot grab last element from an empty list ' );
74
+ throw new OutOfBoundsException ('Cannot grab last element of an empty list ' );
76
75
}
77
76
78
77
return $ this ->sequence [$ key ];
@@ -144,7 +143,7 @@ public static function fromIterable(iterable $iterable): AbstractCypherSequence
144
143
public function get (int $ key )
145
144
{
146
145
if (!array_key_exists ($ key , $ this ->sequence )) {
147
- throw new OutOfBoundsException ();
146
+ throw new OutOfBoundsException (sprintf ( ' Cannot get item in sequence at position: %s ' , $ key ) );
148
147
}
149
148
150
149
return $ this ->sequence [$ key ];
You can’t perform that action at this time.
0 commit comments