# Intelligence

The `Intelligence` class provides methods to interact with various intelligence-related endpoints of the Alphavantage API. It includes methods for fetching news sentiment and top gainers and losers.

### Methods

#### 1. News

Fetches news sentiment for given tickers and topics within a specified time range.

**Signature:**

```php
public function news(
    array $tickers, 
    array $topics = [], 
    ?Carbon $timeFrom = null, 
    ?Carbon $timeTo = null, 
    string $sort = 'LATEST', 
    int $limit = 10000
): array
```

**Parameters:**

* `tickers` (array): An array of stock tickers to fetch news for.
* `topics` (array): An array of topics to filter news by. Default is an empty array.
* `timeFrom` (Carbon|null): The start time for fetching news. Default is null.
* `timeTo` (Carbon|null): The end time for fetching news. Default is null.
* `sort` (string): The sorting order of the news. Must be 'LATEST', 'EARLIEST', or 'RELEVANCE'. Default is 'LATEST'.
* `limit` (int): The maximum number of news items to fetch. Default is 10000.

**Returns:**

* `array`: An array containing the news sentiment data.

**Exceptions:**

* `ApiVolumeReached`
* `ConnectionException`
* `InvalidArgumentException`: Thrown if the sort parameter is invalid.

#### 2. Gainers and Losers

Fetches the top gainers and losers.

**Signature:**

```php
public function gainersAndLosers(): array
```

**Parameters:**

* None

**Returns:**

* `array`: An array containing the top gainers and losers data.

**Exceptions:**

* `ApiVolumeReached`
* `ConnectionException`

***

The `Intelligence` class is designed to provide an easy way to fetch various intelligence-related data using the Alphavantage API. The `news` method allows for fetching news sentiment based on tickers and topics within a specified time range and sort order. The `gainersAndLosers` method fetches the top gainers and losers. Be sure to handle the possible exceptions when using these methods to ensure robust error handling in your application.
