Model/GenderNameModel.php
public function getGender($name)
    {
        if ($record = $this->getRepository()->findOneBy(['name' => strtoupper($name)])) {
            return $record->getGender();
        } else {
            $gender = null;
            try {
                $url         = 'https://api.genderize.io/?name='.urlencode($name);
                $ch          = curl_init($url);
                $curlOptions = [
                    CURLOPT_RETURNTRANSFER => 1,
                    CURLOPT_CONNECTTIMEOUT => 1,
                    CURLOPT_TIMEOUT        => 30,
                ];
                curl_setopt_array($ch, $curlOptions);

                $result = curl_exec($ch);

                if (false !== $result) {
                    $result = json_decode($result, true);
                    if (isset($result['gender'])) {
                        $gender = 'female' === $result['gender'] ? 'F' : 'M';

                        //add it to our reference table
                        $genderName = new PluginEnhancerGenderName();
                        $genderName
                            ->setName(strtoupper($name))
                            ->setGender($gender)
                            ->setProbability($result['probability'])
                            ->setCount($result['count']);
                        $this->getRepository()->saveEntity($genderName, true);
                    }
                }
            } catch (\Exception $e) {
                $this->logger->error(
                    sprintf(
                        '%s (%s) : %s',
                        __FILE__,
                        __LINE__,
                        $e->getMessage()
                    )
                );
            }

            return $gender;
        }
    }
public function getGender($name)
    {
        if ($record = $this->getRepository()->findOneBy(['name' => strtoupper($name)])) {
            return $record->getGender();
        } else {
            $gender = null;
            try {
                $url         = 'https://api.genderize.io/?name='.urlencode($name);
                $ch          = curl_init($url);
                $curlOptions = [
                    CURLOPT_RETURNTRANSFER => 1,
                    CURLOPT_CONNECTTIMEOUT => 1,
                    CURLOPT_TIMEOUT        => 30,
                ];
                curl_setopt_array($ch, $curlOptions);

                $result = curl_exec($ch);

                if (false !== $result) {
                    $result = json_decode($result, true);
                    if (isset($result['gender'])) {
                        $gender = 'female' === $result['gender'] ? 'F' : 'M';

                        //add it to our reference table
                        $genderName = new PluginEnhancerGenderName();
                        $genderName
                            ->setName(strtoupper($name))
                            ->setGender($gender)
                            ->setProbability($result['probability'])
                            ->setCount($result['count']);
                        $this->getRepository()->saveEntity($genderName, true);
                    }
                }
            } catch (\Exception $e) {
                $this->logger->error(
                    sprintf(
                        '%s (%s) : %s',
                        __FILE__,
                        __LINE__,
                        $e->getMessage()
                    )
                );
            }

            return $gender;
        }
    }
@param $name

@return null|string

@throws \Doctrine\ORM\ORMException