Select the version of the api you wish to
query.

@param string $version
@return bool|$this
@return $this
341543
public function selectVersion($version)
	{
		if ( ! in_array($version, $this->versions))
		{
			// not a value version
			return false;
		}

		$this->version = $version;

		return $this;
	}
577621
public function update($version = '', $forceFetching = true) : bool
    {
        $version = $version ?: $this->getVersionAvailable();

        if ($forceFetching) {
            $this->fetch($version);
        }

        $this->preUpdateArtisanCommands();
        $updateStatus = $this->sourceRepository->update($version);
        $this->postUpdateArtisanCommands();

        return $updateStatus;
    }
200984
public function setVersion($version)
    {
        if (null !== $version) {
            Assert::string($version, 'The application version must be a string. Got: %s');
            Assert::notEmpty($version, 'The application version must not be empty.');
        }

        $this->version = $version;

        return $this;
    }
1042524
public function setVersion($version)
    {
        $availableVersions = ['v1'];

        if (in_array($version, $availableVersions)) {
            $this->version = $version;

            $this->initConfiguration();

            return $this;
        }

        throw new InvalidArgument(
            'Invalid Consumer API version, available versions are: ' . implode(', ', $availableVersions)
        );
    }
1052830
protected function setVersion($version) {
		$this->version = $version;

		$numbers = explode('.', $version);

		// Update Mayor and Minor-Version-Numbers
		$this->setMayor((int) $numbers[0]);
		$this->setMinor((int) $numbers[1]);
	}
435435
public function setAPIversion($version = '1')
    {
        preg_match('/\d+/', trim($version), $matches);

        if (count($matches) === 1) {
            $this->api_version = $matches[0];
        }
    }
1305634
public function compareTo($version)
    {
        $cmp = self::parse($version);
        $result = $this->cmp($cmp, $this->numbers);
        if ($result === 0) {
            $result = $this->cmp($this->numbers, $cmp);
            $result = - $result;
        } else {
            return $result;
        }
        return $result;
    }
656917
protected function setVersion($version)
    {
        $cleanVer = $this->cleanVersion($version);

        if ($cleanVer == '') {
            $this->_version = self::VERSION_UNKNOWN;
        } else {
            $this->_version = $cleanVer;
        }
    }
778561
public function index($version = null)
    {
        try {
            $request = new ServiceRequest();
            if (!empty($version)) {
                $request->setApiVersion($version);
            }

            Log::info('[REQUEST]', [
                'API Version' => $request->getApiVersion(),
                'Method'      => $request->getMethod(),
                'Service'     => null,
                'Resource'    => null
            ]);

            Log::debug('[REQUEST]', [
                'Parameters' => json_encode($request->getParameters(), JSON_UNESCAPED_SLASHES),
                'API Key'    => $request->getHeader('X_DREAMFACTORY_API_KEY'),
                'JWT'        => $request->getHeader('X_DREAMFACTORY_SESSION_TOKEN')
            ]);

            $limitedFields = ['id', 'name', 'label', 'description', 'type'];
            $fields = \Request::query(ApiOptions::FIELDS);
            if (!empty($fields) && !is_array($fields)) {
                $fields = array_map('trim', explode(',', trim($fields, ',')));
            } elseif (empty($fields)) {
                $fields = $limitedFields;
            }
            $fields = array_intersect($fields, $limitedFields);

            $group = \Request::query('group');
            $type = \Request::query('type');
            if (!empty($group)) {
                $results = ServiceManager::getServiceListByGroup($group, $fields, true);
            } elseif (!empty($type)) {
                $results = ServiceManager::getServiceListByType($type, $fields, true);
            } else {
                $results = ServiceManager::getServiceList($fields, true);
            }
            $services = [];
            foreach ($results as $info) {
                // only allowed services by role here
                if (Session::allowsServiceAccess(array_get($info, 'name'))) {
                    $services[] = $info;
                }
            }

            if (!empty($group)) {
                $results = ServiceManager::getServiceTypes($group);
            } elseif (!empty($type)) {
                $results = [ServiceManager::getServiceType($type)];
            } else {
                $results = ServiceManager::getServiceTypes();
            }
            $types = [];
            foreach ($results as $type) {
                $types[] = [
                    'name'        => $type->getName(),
                    'label'       => $type->getLabel(),
                    'group'       => $type->getGroup(),
                    'description' => $type->getDescription()
                ];
            }
            $response = ResponseFactory::create(['services' => $services, 'service_types' => $types]);
            Log::info('[RESPONSE]', ['Status Code' => $response->getStatusCode(), 'Content-Type' => $response->getContentType()]);

            return ResponseFactory::sendResponse($response, $request);
        } catch (\Exception $e) {
            return ResponseFactory::sendException($e, (isset($request) ? $request : null));
        }
    }
1193800
public static function phpVersion($version)
    {
        static $phpVerisons = [];

        $version = (string)$version;

        if (!isset($phpVerisons[$version])) {
            $phpVerisons[$version] = version_compare(PHP_VERSION, $version, '>=');
        }
        return $phpVerisons[$version];
    }
1212628
public function setVersion(string $version)
    {

        if (substr($version, 0, 1) !== '/')
            $version = '/' . $version;

        $this->version = $version;

        return $this;
    }
1082190
public function version($version = null)
    {
        if (func_num_args() === 0) {
            return $this->_version;
        }
        $headers = $this->headers();
        $headers->prepend('MIME-Version', $version);
        $this->_version = $version;
        return $this;
    }
738282
public static function toVersion($version)
    {
        $components = self::toComponents($version);

        return new Version(
            $components['major'],
            $components['minor'],
            $components['patch'],
            $components['pre'],
            $components['build']
        );
    }
948707
public function addVersion( PhpVersion $version ) {
		$versionString = $version->getVersion();

		$this->phpVersions[$versionString] = $version;

		return $this;
	}
943058
public function withProtocolVersion($version)
    {
        if (!is_string($version)) {
            throw new \InvalidArgumentException("Expected protocol version to be a string");
        }
        
        $this->protocolVersion = $version;
        
        $this->sendStatusHeader();
        
        return $this;
    }
1173187
public function withProtocolVersion($version)
    {
        if (in_array($version, ['1.0', '1.1', '2.0']) === false) {
            throw new InvalidArgumentException('You may only use a valid http protocol version, %d provided', $version);
        }

        return $this->_clone('protocol', $version);
    }
1251800
protected function getLastEditedForVersion($version)
    {
        Deprecation::notice('5.0', 'Use getLastEditedAndStageForVersion instead');
        $result = $this->getLastEditedAndStageForVersion($version);
        if ($result) {
            return reset($result);
        }
        return null;
    }