public function getProjects($refresh = null)
    {
        $cacheKey = sprintf('%s:projects', $this->sessionId);

        /** @var Project[] $projects */
        $projects = [];

        $cached = $this->cache->fetch($cacheKey);

        if ($refresh === false && !$cached) {
            return [];
        } elseif ($refresh || !$cached) {
            foreach ($this->getClient()->getProjects() as $project) {
                $projects[$project->id] = $project;
            }

            $cachedProjects = [];
            foreach ($projects as $id => $project) {
                $cachedProjects[$id] = $project->getData();
                $cachedProjects[$id]['_endpoint'] = $project->getUri(true);
            }

            $this->cache->save($cacheKey, $cachedProjects, $this->config->get('api.projects_ttl'));
        } else {
            $guzzleClient = $this->getHttpClient();
            foreach ((array) $cached as $id => $data) {
                $projects[$id] = new Project($data, $data['_endpoint'], $guzzleClient);
            }
        }

        return $projects;
    }
public function getProjects($refresh = null)
    {
        $cacheKey = sprintf('%s:projects', $this->sessionId);

        /** @var Project[] $projects */
        $projects = [];

        $cached = $this->cache->fetch($cacheKey);

        if ($refresh === false && !$cached) {
            return [];
        } elseif ($refresh || !$cached) {
            foreach ($this->getClient()->getProjects() as $project) {
                $projects[$project->id] = $project;
            }

            $cachedProjects = [];
            foreach ($projects as $id => $project) {
                $cachedProjects[$id] = $project->getData();
                $cachedProjects[$id]['_endpoint'] = $project->getUri(true);
            }

            $this->cache->save($cacheKey, $cachedProjects, $this->config->get('api.projects_ttl'));
        } else {
            $guzzleClient = $this->getHttpClient();
            foreach ((array) $cached as $id => $data) {
                $projects[$id] = new Project($data, $data['_endpoint'], $guzzleClient);
            }
        }

        return $projects;
    }
public function getProjects ( $ refresh = null ) { $ cacheKey = sprintf ( '%s:projects' , $ this -> sessionId ) ; /** @var Project[] $projects */ $ projects = [ ] ; $ cached = $ this -> cache -> fetch ( $ cacheKey ) ; if ( $ refresh === false && ! $ cached ) { return [ ] ; } elseif ( $ refresh || ! $ cached ) { foreach ( $ this -> getClient ( ) -> getProjects ( ) as $ project ) { $ projects [ $ project -> id ] = $ project ; } $ cachedProjects = [ ] ; foreach ( $ projects as $ id => $ project ) { $ cachedProjects [ $ id ] = $ project -> getData ( ) ; $ cachedProjects [ $ id ] [ '_endpoint' ] = $ project -> getUri ( true ) ; } $ this -> cache -> save ( $ cacheKey , $ cachedProjects , $ this -> config -> get ( 'api.projects_ttl' ) ) ; } else { $ guzzleClient = $ this -> getHttpClient ( ) ; foreach ( ( array ) $ cached as $ id => $ data ) { $ projects [ $ id ] = new Project ( $ data , $ data [ '_endpoint' ] , $ guzzleClient ) ; } } return $ projects ; }
Return the user's projects.

@param bool|null $refresh Whether to refresh the list of projects.

@return Project[] The user's projects, keyed by project ID.
Return the user s projects .