/**
  * @return array
  */
 protected function _getData()
 {
     $interactor = new CurlInteractor();
     $interactor->setResponseFactory(new SlackResponseFactory());
     $commander = new Commander($this->_token, $interactor);
     $x = $commander->execute('channels.list');
     return Arrays::value($x->getBody(), 'channels', []);
 }
 /**
  * @return mixed
  */
 protected function _getData()
 {
     $interactor = new CurlInteractor();
     $interactor->setResponseFactory(new SlackResponseFactory());
     $commander = new Commander($this->_token, $interactor);
     $x = $commander->execute('channels.history', ['channel' => $this->_channelId, 'inclusive' => 1, 'count' => 100]);
     return Arrays::value($x->getBody(), 'messages', []);
 }
Esempio n. 3
0
 public function getMessage()
 {
     if ($this->isSuccess()) {
         return 'Invitation sent';
     } else {
         $error = Arrays::value($this->getResponse(), 'error', 'Error');
         return $this->_decodeErrorMessage($error);
     }
 }
Esempio n. 4
0
 /**
  * Hydrate the public properties
  *
  * @param $data
  */
 public function hydrate($data)
 {
     if ($data && $this->_hydratePublic) {
         foreach ($this->toArray() as $key => $value) {
             if (is_array($data)) {
                 $this->{$key} = Arrays::value($data, $key, $value);
             } else {
                 if (is_object($data)) {
                     $this->{$key} = Objects::property($data, $key, $value);
                 }
             }
         }
     }
 }
Esempio n. 5
0
 public function __construct($uri)
 {
     $uri = (string) $uri;
     $matches = null;
     if (preg_match('(^([^/:]*://[^/]*)(\\?.*)\\z)', $uri, $matches)) {
         // If the URI is something like `idea://open?file=/path/to/file`, the
         // `parse_url()` function will parse `open?file=` as the host. This is
         // not the expected result. Break the URI into two pieces, stick a slash
         // in between them, parse that, then remove the path. See T6106.
         $parts = parse_url($matches[1] . '/' . $matches[2]);
         unset($parts['path']);
     } else {
         $parts = parse_url($uri);
     }
     // The parse_url() call will accept URIs with leading whitespace, but many
     // other tools (like git) will not. See T4913 for a specific example. If
     // the input string has leading whitespace, fail the parse.
     if ($parts) {
         if (ltrim($uri) != $uri) {
             $parts = false;
         }
     }
     // NOTE: `parse_url()` is very liberal about host names; fail the parse if
     // the host looks like garbage.
     if ($parts) {
         $host = Arrays::value($parts, 'host', '');
         if (!preg_match('/^([a-zA-Z0-9\\.\\-]*)$/', $host)) {
             $parts = false;
         }
     }
     if (!$parts) {
         $parts = [];
     }
     // stringyness is to preserve API compatibility and
     // allow the tests to continue passing
     $this->setProtocol(Arrays::value($parts, 'scheme', ''));
     $this->setUser(rawurldecode(Arrays::value($parts, 'user', '')));
     $this->setPass(rawurldecode(Arrays::value($parts, 'pass', '')));
     $this->setDomain(Arrays::value($parts, 'host', ''));
     $this->setPort((string) Arrays::value($parts, 'port', ''));
     $this->setPath(Arrays::value($parts, 'path', ''));
     parse_str(Arrays::value($parts, 'query'), $this->query);
     $this->setFragment(Arrays::value($parts, 'fragment', ''));
 }
Esempio n. 6
0
 public static function getClientIp()
 {
     static $ip;
     if ($ip === null) {
         $ipKeys = ['HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR'];
         foreach ($ipKeys as $ipKey) {
             $ipString = Arrays::value($_SERVER, $ipKey);
             if ($ipString !== null) {
                 foreach (explode(",", $ipString) as $ip) {
                     if (filter_var($ip, FILTER_VALIDATE_IP) !== false) {
                         return $ip;
                     }
                 }
             }
         }
         $ip = "";
     }
     return $ip;
 }
Esempio n. 7
0
 public function getLinks()
 {
     $id = $this->getApp()->id;
     $links = [];
     $links['Steam Community'] = 'https://steamcommunity.com/app/' . $id;
     $links['Steam Store'] = 'http://store.steampowered.com/app/' . $id;
     $links['Official Website'] = $this->getApp()->website;
     $arr = $this->getApp()->support_info ?: '[]';
     $arr = json_decode($arr, true);
     $links['Support Site'] = Arrays::value($arr, 'url');
     $arr = $this->getApp()->metacritic ?: '[]';
     $arr = json_decode($arr, true);
     $links['Metacritic'] = Arrays::value($arr, 'url');
     $return = [];
     foreach ($links as $k => $v) {
         if ($v) {
             $return[] = new Tr(new Td(new A($v, $k)));
         }
     }
     return (new Table())->setContent($return)->addClass('table table-hover');
 }
Esempio n. 8
0
 public function getValueRow()
 {
     $cols = [new Th('Value')];
     foreach (SortFieldEnum::all() as $col) {
         $value = Arrays::value($this->getUser(), $col, 0);
         $formatted = number_format($value);
         switch ($col) {
             case SortFieldEnum::LEVEL:
                 $val = new A('/experience/' . $value, $formatted);
                 break;
             case SortFieldEnum::TIME:
                 $val = $this->getMinutes($value * 60);
                 break;
             default:
                 $val = $formatted;
                 break;
         }
         $cols[] = new Td($val);
     }
     return new Tr($cols);
 }
Esempio n. 9
0
 public function getClasses()
 {
     return (array) Arrays::value($this->_attributes, 'class', []);
 }
 /**
  * @param int $steamId
  *
  * @return BadgesResponse
  *
  * @throws SteamException
  */
 public function getBadges($steamId)
 {
     $path = 'GetBadges/v1';
     $query = ['steamId' => $steamId];
     $data = $this->_get($path, $query)['response'];
     if (!$data) {
         return new BadgesResponse();
     }
     $badges = new BadgesResponse(['playerXp' => $data['player_xp'], 'playerLevel' => $data['player_level'], 'playerXpNeededToLevelUp' => $data['player_xp_needed_to_level_up'], 'playerXpNeededCurrentLevel' => $data['player_xp_needed_current_level'], 'badges' => Arrays::value($data, 'badges', [])]);
     $items = [];
     foreach ($badges->badges as $badge) {
         $items[] = new BadgeResponse(['id' => $badge['badgeid'], 'level' => $badge['level'], 'completion_time' => $badge['completion_time'], 'xp' => $badge['xp'], 'scarcity' => $badge['scarcity']]);
     }
     $badges->badges = $items;
     return $badges;
 }
Esempio n. 11
0
 public static function get($key, $default = null)
 {
     return Arrays::value($_SESSION, $key, $default);
 }
 public function ajaxSearchMaintainersInit()
 {
     $data = $this->_getRequest()->query->all();
     $ids = Arrays::value($data, 'ids', '');
     $ids = explode(',', $ids);
     $ids = array_filter($ids);
     asort($ids);
     $memcache = new \Memcached();
     $key = 'searchMaintainersInit-' . implode('-', $ids);
     $searchMaintainersInit = $memcache->get($key);
     if ($searchMaintainersInit === false) {
         if (!$ids) {
             return [];
         }
         $authors = Maintainer::select('id', 'name')->whereIn('id', $ids)->orderBy('name', 'asc')->get();
         $searchMaintainersInit = [];
         foreach ($authors as $item) {
             $searchMaintainersInit[] = ['id' => $item->id, 'text' => $item->name];
         }
         $memcache->set($key, $searchMaintainersInit, self::WEEK);
     }
     return $searchMaintainersInit;
 }
Esempio n. 13
0
 /**
  * @return string
  */
 public function getRequestHeader()
 {
     return Arrays::value($this->_info, 'request_header');
 }
Esempio n. 14
0
 /**
  * Get all changed properties since load
  *
  * @return array[property] => ['from' => '','to' => '']
  */
 public function getDaoChanges()
 {
     $current = $this->getDaoPropertyData();
     $changes = [];
     foreach ($current as $key => $val) {
         if ($val !== $this->_savedData[$key]) {
             if ($this->{$key} instanceof Counter && !$this->{$key}->hasChanged()) {
                 continue;
             }
             $changes[$key] = ['from' => Arrays::value($this->_savedData, $key), 'to' => Arrays::value($current, $key)];
         }
     }
     return $changes;
 }
Esempio n. 15
0
 protected function _getRouteData($key = null, $default = null)
 {
     if ($key === null) {
         return $this->_processParams;
     }
     return Arrays::value($this->_processParams, $key, $default);
 }
Esempio n. 16
0
 public function testIdx()
 {
     $array = ['present' => true, 'null' => null];
     $this->assertEquals(true, Arrays::value($array, 'present'));
     $this->assertEquals(true, Arrays::value($array, 'present', false));
     $this->assertEquals(null, Arrays::value($array, 'null'));
     $this->assertEquals(null, Arrays::value($array, 'null', false));
     $this->assertEquals(null, Arrays::value($array, 'missing'));
     $this->assertEquals(false, Arrays::value($array, 'missing', false));
 }
Esempio n. 17
0
 /**
  * @return ForumCategoriesResponse[]
  */
 public function getForumCategories()
 {
     $response = $this->_get(['action' => 'forum', 'type' => 'main']);
     $response = Arrays::value($response, 'categories', []);
     foreach ($response as $k => $section) {
         $response[$k] = new ForumCategoriesResponse($section);
         foreach ($response[$k]->forums as $k2 => $result) {
             $response[$k]->forums[$k2] = new ForumCategoriesResultResponse($result);
         }
     }
     return $response;
 }
Esempio n. 18
0
 /**
  * Retrieve the current visitor ID from the $_COOKIE global
  *
  * @return string|null
  */
 public function getVisitorIdCookie()
 {
     return Arrays::value($_COOKIE, CookieReference::VISITOR_ID);
 }
Esempio n. 19
0
 /**
  * Get the description of a feature
  *
  * @param $featureCode
  *
  * @return string
  */
 public static function getDescription($featureCode)
 {
     return Arrays::value(self::$features, $featureCode)[1];
 }
Esempio n. 20
0
 public function getOrder($field, $default = 'ASC')
 {
     return Arrays::value($this->_order, array_search($field, $this->_fields), $default);
 }
Esempio n. 21
0
 /**
  * Access an array index, retrieving the value stored there if it exists or
  * a default if it does not. This function allows you to concisely access an
  * index which may or may not exist without raising a warning.
  *
  * @param   $array   array  Array to access.
  * @param   $key     mixed  Index to access in the array.
  * @param   $default mixed  Default value to return if the key is not
  *                   present in the array.
  *
  * @return  mixed  If $array[$key] exists, that value is returned. If not,
  *                  $default is returned without raising a warning.
  * @group      util
  *
  * @deprecated
  */
 function idx(array $array, $key, $default = null)
 {
     return \Packaged\Helpers\Arrays::value($array, $key, $default);
 }