public static function search($query, ConsoleLogger $logger = null)
    {
        $handler = \GuzzleHttp\HandlerStack::create();
        if (isset($logger)) {
            $handler->push(\GuzzleHttp\Middleware::log(
                $logger,
                new \GuzzleHttp\MessageFormatter('{req_headers}'.PHP_EOL.'{req_body}')
            ));
        }
        self::$client = new \GuzzleHttp\Client(['cookies' => true, 'handler' => $handler]);
        self::$client->request(
            'GET',
            self::BASEURL.'services/entreprise/rest/recherche/parPhrase',
            [
                'query' => [
                    'phrase'                => $query,
                    'typeProduitMisEnAvant' => 'EXTRAIT',
                ],
            ]
        );

        self::$client->request(
            'GET',
            self::BASEURL.'societes/recherche-entreprise-dirigeants/'.
            'resultats-entreprise-dirigeants.html'
        );
        $response = self::$client->request(
            'GET',
            'https://www.infogreffe.fr/services/entreprise/rest/recherche/'.
            'derniereRechercheEntreprise'
        );
        $response = json_decode($response->getBody());
        $idsRCS = $idsNoRCS = $idsRemovedRCS = [];
        foreach ($response->entrepRCSStoreResponse->items as $result) {
            if (isset($result->id)) {
                $idsRCS[] = $result->id;
            }
        }
        if (isset($response->entrepRadieeStoreResponse)) {
            foreach ($response->entrepRadieeStoreResponse->items as $result) {
                if (isset($result->id)) {
                    $idsRemovedRCS[] = $result->id;
                }
            }
        }
        foreach ($response->entrepHorsRCSStoreResponse->items as $result) {
            if (isset($result->id)) {
                $idsNoRCS[] = $result->id;
            }
        }
        $items = [];
        if (!empty($idsRCS)) {
            $items = array_merge($items, self::getItems($idsRCS, 'ENTREP_RCS_ACTIF'));
        }
        if (!empty($idsRemovedRCS)) {
            $items = array_merge($items, self::getItems($idsRemovedRCS, 'ENTREP_RCS_RADIES'));
        }
        if (!empty($idsNoRCS)) {
            $items = array_merge($items, self::getItems($idsNoRCS, 'ENTREP_HORS_RCS'));
        }

        return self::getArrayFromJSON($items);
    }