File tree Expand file tree Collapse file tree 2 files changed +40
-4
lines changed
Expand file tree Collapse file tree 2 files changed +40
-4
lines changed Original file line number Diff line number Diff line change 22
33namespace Typesense ;
44
5- class AnalyticsRules
5+ class AnalyticsRules implements \ArrayAccess
66{
77 const RESOURCE_PATH = '/analytics/rules ' ;
88
@@ -36,4 +36,40 @@ private function endpoint_path($operation = null)
3636 {
3737 return self ::RESOURCE_PATH . ($ operation === null ? '' : "/ $ operation " );
3838 }
39+
40+ /**
41+ * @inheritDoc
42+ */
43+ public function offsetExists ($ offset ): bool
44+ {
45+ return isset ($ this ->analyticsRules [$ offset ]);
46+ }
47+
48+ /**
49+ * @inheritDoc
50+ */
51+ public function offsetGet ($ offset ): AnalyticsRule
52+ {
53+ if (!isset ($ this ->analyticsRules [$ offset ])) {
54+ $ this ->analyticsRules [$ offset ] = new AnalyticsRule ($ offset , $ this ->apiCall );
55+ }
56+
57+ return $ this ->analyticsRules [$ offset ];
58+ }
59+
60+ /**
61+ * @inheritDoc
62+ */
63+ public function offsetSet ($ offset , $ value ): void
64+ {
65+ $ this ->analyticsRules [$ offset ] = $ value ;
66+ }
67+
68+ /**
69+ * @inheritDoc
70+ */
71+ public function offsetUnset ($ offset ): void
72+ {
73+ unset($ this ->analyticsRules [$ offset ]);
74+ }
3975}
Original file line number Diff line number Diff line change @@ -44,17 +44,17 @@ public function testCanUpsertARule(): void
4444
4545 public function testCanRetrieveARule (): void
4646 {
47- $ returnData = $ this ->client ()->analytics ->rules ()->{ $ this ->ruleName } ->retrieve ();
47+ $ returnData = $ this ->client ()->analytics ->rules ()[ $ this ->ruleName ] ->retrieve ();
4848 $ this ->assertEquals ($ returnData ['name ' ], $ this ->ruleName );
4949 }
5050
5151 public function testCanDeleteARule (): void
5252 {
53- $ returnData = $ this ->client ()->analytics ->rules ()->{ $ this ->ruleName } ->delete ();
53+ $ returnData = $ this ->client ()->analytics ->rules ()[ $ this ->ruleName ] ->delete ();
5454 $ this ->assertEquals ($ returnData ['name ' ], $ this ->ruleName );
5555
5656 $ this ->expectException (ObjectNotFound::class);
57- $ this ->client ()->analytics ->rules ()->{ $ this ->ruleName } ->retrieve ();
57+ $ this ->client ()->analytics ->rules ()[ $ this ->ruleName ] ->retrieve ();
5858 }
5959
6060 public function testCanRetrieveAllRules (): void
You can’t perform that action at this time.
0 commit comments