99 * @author Thomas Kuschan
1010 * @copyright (c) 2023
1111 */
12- class Log extends \ArrayIterator implements \ArrayAccess {
12+ class Log extends \ArrayIterator implements \ArrayAccess
13+ {
1314 /**
1415 * Create a Log from a group of records
1516 * @param LogRecord ...$records One or more log entries
1617 * @no-named-arguments This will disallow named parameters and force $records to array<int, LogRecord>
1718 */
18- public function __construct (LogRecord ...$ records ) {
19+ public function __construct (LogRecord ...$ records )
20+ {
1921 parent ::__construct ($ records );
2022 }
2123
@@ -24,9 +26,11 @@ public function __construct(LogRecord ...$records) {
2426 * @param bool $ascending Sorting order, defaults to false (meaning it sorts descending)
2527 * @return void
2628 */
27- public function sortByDatetime (bool $ ascending = false ): void {
28- if (count ($ this ) == 0 )
29+ public function sortByDatetime (bool $ ascending = false ): void
30+ {
31+ if (count ($ this ) == 0 ) {
2932 return ;
33+ }
3034
3135 // get the stored elements and rebuild the log
3236 $ array = $ this ->getArrayCopy ();
@@ -39,12 +43,13 @@ public function sortByDatetime(bool $ascending = false): void {
3943 if ($ ascending ) {
4044 $ array = array_reverse ($ array );
4145 }
42-
46+
4347 // finally set this array as the new content for us
4448 parent ::__construct ($ array );
4549 }
4650
47- public function current (): LogRecord {
51+ public function current (): LogRecord
52+ {
4853 return parent ::current ();
4954 }
5055
@@ -54,14 +59,16 @@ public function current(): LogRecord {
5459 * @throws \OutOfBoundsException When the offset is not defined
5560 * @return LogRecord
5661 */
57- public function offsetGet (mixed $ offset ): LogRecord {
58- if (parent ::offsetExists ($ offset )) {
62+ public function offsetGet (mixed $ offset ): LogRecord
63+ {
64+ if (parent ::offsetExists ($ offset )) {
5965 $ offset = parent ::offsetGet ($ offset );
60- if ($ offset !== null )
66+ if ($ offset !== null ) {
6167 return $ offset ;
68+ }
6269 }
6370 // exit with exception
64- throw new \OutOfBoundsException ('Undefined array key ' . $ offset );
71+ throw new \OutOfBoundsException ('Undefined array key ' . $ offset );
6572 }
6673
6774 /**
@@ -71,7 +78,8 @@ public function offsetGet(mixed $offset): LogRecord {
7178 * @throws \LogicException Always
7279 * @return void
7380 */
74- public function offsetSet (mixed $ offset , mixed $ value ): void {
81+ public function offsetSet (mixed $ offset , mixed $ value ): void
82+ {
7583 // we do not support setting in any way
7684 throw new \LogicException ('Unsupported operation ' );
7785 }
@@ -82,7 +90,8 @@ public function offsetSet(mixed $offset, mixed $value): void {
8290 * @throws \LogicException Always
8391 * @return void
8492 */
85- public function offsetUnset (mixed $ offset ): void {
93+ public function offsetUnset (mixed $ offset ): void
94+ {
8695 throw new \LogicException ('Unsupported operation ' );
8796 }
8897}
0 commit comments