'USD', 'curs_eur' => 'EUR', 'curs_cny' => 'CNY', 'curs_btc' => 'BTC', 'temperature' => 'temperature' ]; } /** * {@inheritdoc} */ public static function GetŠ”urrency() { return \Yii::$app->cache->getOrSet("curce", function (){ $request = @file_get_contents( self::$filecbr ); if( $request ){ $request = json_decode($request, true); if( isset($request['Valute']['USD']) && isset($request['Valute']['EUR']) && isset($request['Valute']['CNY']) ){ $result['last_updated'] = date('Y-m-d H:i:s', strtotime($request['Date'])); //USD $result['USD']['value'] = round($request['Valute']['USD']['Value'], 2); $result['USD']['dynamics'] = $request['Valute']['USD']['Value']>$request['Valute']['USD']['Previous']?'up':'down'; //EUR $result['EUR']['value'] = round($request['Valute']['EUR']['Value'], 2); $result['EUR']['dynamics'] = $request['Valute']['EUR']['Value']>$request['Valute']['CNY']['Previous']?'up':'down'; //CNY $result['CNY']['value'] = round($request['Valute']['CNY']['Value']/$request['Valute']['CNY']['Nominal'], 2); $result['CNY']['dynamics'] = $request['Valute']['CNY']['Value']>$request['Valute']['CNY']['Previous']?'up':'down'; $request2 = @file_get_contents( self::$filebtc ); $result['BTC']['value'] = 0; $result['BTC']['dynamics'] = ''; if( $request2 ){ $request2 = json_decode($request2, true); if( isset($request2['USD']['last']) ){ $result['BTC']['value'] = round($request2['USD']['last'], 2); $result['BTC']['dynamics'] = $request2['USD']['15m']>$request2['USD']['last']?'up':'down'; } } return $result; } }else{ return false; } }, 7200 ); } public static function GetTemperature() { return \Yii::$app->cache->getOrSet("temperature", function (){ $request = @file_get_contents( self::$filetemp ); if( $request ){ return $request; } return false; }, 1); } }