File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -48,30 +48,26 @@ abstract class AbstractMap implements SortedMap
4848 */
4949 public function __get ($ property )
5050 {
51- switch ($ property ) {
52- case 'comparator ' :
53- return $ this ->comparator ();
54- case 'firstKey ' :
55- return $ this ->firstKey ();
56- case 'lastKey ' :
57- return $ this ->lastKey ();
58- case 'firstValue ' :
59- return $ this ->firstValue ();
60- case 'lastValue ' :
61- return $ this ->lastValue ();
62- case 'first ' :
63- return $ this ->first ();
64- case 'last ' :
65- return $ this ->last ();
66- case 'keys ' :
67- return $ this ->keys ();
68- case 'values ' :
69- return $ this ->values ();
70- case 'count ' :
71- return $ this ->count ();
72- default :
73- throw new \RuntimeException ('Undefined property ' );
51+ $ map = array (
52+ 'comparator ' => 'comparator ' ,
53+ 'firstKey ' => 'firstKey ' ,
54+ 'lastKey ' => 'lastKey ' ,
55+ 'firstValue ' => 'firstValue ' ,
56+ 'lastValue ' => 'lastValue ' ,
57+ 'first ' => 'first ' ,
58+ 'last ' => 'last ' ,
59+ 'keys ' => 'keys ' ,
60+ 'values ' => 'values ' ,
61+ 'count ' => 'count ' ,
62+ );
63+
64+ if (!isset ($ map [$ property ])) {
65+ throw new \RuntimeException ('Undefined property ' );
7466 }
67+
68+ $ method = $ map [$ property ];
69+
70+ return $ this ->$ method ();
7571 }
7672
7773 /**
You can’t perform that action at this time.
0 commit comments