File tree Expand file tree Collapse file tree 3 files changed +19
-15
lines changed
Expand file tree Collapse file tree 3 files changed +19
-15
lines changed Original file line number Diff line number Diff line change @@ -123,22 +123,27 @@ public function getDeviceByIdx(int $idx) {
123123 switch ($ receivedDevice ->Type ) {
124124
125125 case 'Light/Switch ' :
126- return $ this -> getLightSwitch ( $ receivedDevice )->get ();
126+ return ( new Factories \ LightSwitchFactory ( $ receivedDevice) )->get ();
127127 break ;
128128
129129 case 'Lighting 2 ' :
130- return $ this -> getLighting2 ( $ receivedDevice )->get ();
130+ return ( new Lighting2Factory ( $ receivedDevice) )->get ();
131131 break ;
132132
133133 case 'Temp + Humidity ' :
134- return $ this -> getTempAndHumidity ( $ receivedDevice )->get ();
134+ return ( new TempAndHumidityFactory ( $ receivedDevice) )->get ();
135135 break ;
136136
137137 case 'Thermostat ' :
138- return $ this ->getThermostat ($ receivedDevice )->get ();
138+ return (new ThermostatFactory ($ receivedDevice ))->get ();
139+ break ;
140+
141+ case 'Usage ' :
142+ return (new UsageFactory ($ receivedDevice ))->get ();
139143 break ;
140144
141145 default :
146+ return null ;
142147
143148 }
144149 }
Original file line number Diff line number Diff line change @@ -20,16 +20,16 @@ public function __construct(AbstractDevice $device)
2020 }
2121
2222 /**
23- * @return string
23+ * @return array
2424 */
25- public function getStatus () {
26- return $ this -> device -> getStatus ( );
27- }
28-
29- /**
30- * @return \DateTime
31- */
32- public function getLastUpdate () {
33- return $ this -> device -> getLastUpdate () ;
25+ public function getMethods () {
26+ $ class = new \ ReflectionClass ( get_class ( $ this ) );
27+ $ availableMethods = [];
28+ foreach ( $ class -> getMethods (\ReflectionMethod:: IS_PUBLIC ) as $ method ) {
29+ if ( $ method -> name !== ' __construct ' ) {
30+ $ availableMethods [] = $ method -> name ;
31+ }
32+ }
33+ return $ availableMethods ;
3434 }
3535}
Original file line number Diff line number Diff line change 88 */
99interface ControllerInterface
1010{
11- public function getStatus ();
1211
1312}
You can’t perform that action at this time.
0 commit comments