Find the path for a new SSH key.

If the file already exists, this will recurse to find a new filename. The
first will be "id_rsa", the second "id_rsa2", the third "id_rsa3", and so
on.

@param int $number

@return string
504196
protected function getNewKeyPath($number = 1)
    {
        $basename = self::DEFAULT_BASENAME;
        if ($number > 1) {
            $basename = strpos($basename, '.key')
                ? str_replace('.key', '.' . $number . 'key', $basename)
                : $basename . '.' . $number;
        }
        /** @var \Platformsh\Cli\Service\Filesystem $fs */
        $fs = $this->getService('fs');
        $filename = $fs->getHomeDirectory() . '/.ssh/' . $basename;
        if (file_exists($filename)) {
            return $this->getNewKeyPath(++$number);
        }

        return $filename;
    }
566699
public function hasKey(string $key): bool
    {
        return $key && strpos($key, '@@') === false && file_exists($this->getPathFromKey($key));
    }
662269
private static function executeStep3($number) {
        $codewords = array();
        $codewords[9] = (int)bcmod($number, '636');
        $number = bcdiv($number, '636', 0);

        for ($i = 8; $i >= 0; $i--) {
            $codewords[$i] = (int)bcmod($number, '1365');
            $number = bcdiv($number, '1365', 0);
        }

        return $codewords;
    }
567153
private function strConst($number) {
        static $lookup;
        if (!$lookup) {
            $lookup = array();
            $r = new ReflectionClass('HTML5_TreeBuilder');
            $consts = $r->getConstants();
            foreach ($consts as $const => $num) {
                if (!is_int($num)) continue;
                $lookup[$num] = $const;
            }
        }
        return $lookup[$number];
    }
156834
public function get($number=null)
    {
      $url = URIResource::Make($this->path, array($number));
      $data = $this->client->get($url, array(), true, false);

      return Constructor::Make($this, $data);
    }
1074237
public function seeNumberNewLines($number)
    {
        $lines = preg_split('/\n|\r/', $this->file);

        $this->assertTrue(
            (int) $number === count($lines),
            "The number of new lines does not match with $number"
        );
    }
567569
protected function asString($number, $digits = 2) {
		$number = (string)$number;
		$count = mb_strlen($number);
		while ($count < $digits) {
			$number = '0' . $number;
			$count++;
		}
		return $number;
	}
141678
public static function getNextPermutation($number) {
    $length = strlen($number);
    $pieces = str_split($number);
    // Find non-increasing suffix
    $i = $length - 1;
    while ($i > 0 && $pieces[$i - 1] >= $pieces[$i]) {
      $i--;
    }
    if ($i <= 0) {
      return FALSE;
    }

    // Find successor to pivot.
    $j = $length - 1;
    while ($pieces[$j] <= $pieces[$i - 1]) {
      $j--;
    }
    $temp = $pieces[$i - 1];
    $pieces[$i - 1] = $pieces[$j];
    $pieces[$j] = $temp;

    // Reverse suffix
    $j = $length - 1;
    while ($i < $j) {
      $temp = $pieces[$i];
      $pieces[$i] = $pieces[$j];
      $pieces[$j] = $temp;
      $i++;
      $j--;
    }
    return implode('', $pieces);
  }
1038516
protected function path($key)
	{
		$parts = explode('.', $key);

		$path = array_shift($parts);
		$path = $this->directory . ($path ? DIRECTORY_SEPARATOR . $this->cleanPath($path) : '');

		return $path . DIRECTORY_SEPARATOR . $this->id($key) . '.php';
	}
992167
protected function getFileName($key)
    {
        $file = $this->getFilePath() . $this->encrypt($key) . $this->fileExtension;

        return $file;
    }
828411
private function getCacheFilePath($key)
    {
        $hash = hash('sha256', $key);
        $subdir = substr($hash, 0, 2);
        $filename = substr($hash, 2);

        return $this->cacheDir
            . DIRECTORY_SEPARATOR
            . $subdir
            . DIRECTORY_SEPARATOR
            . $filename
        ;
    }
1117841
public function getKeyPath($key)
    {

        $key = str_replace('.', '/', trim($key, '.'));

        return implode('', [$this->_path, "/$key", $this->_format->getExtension()]);
    }
456873
private function getFilePath($key)
    {
        if (!preg_match('|^[a-zA-Z0-9_\.! ]+$|', $key)) {
            throw new InvalidArgumentException(sprintf('Invalid key "%s". Valid filenames must match [a-zA-Z0-9_\.! ].', $key));
        }

        return sprintf('%s/%s', $this->folder, $key);
    }
760939
protected function getFilename($key)
    {
        $sha1 = sha1($key);
        $result = $this->path . '/' . substr($sha1, 0, 2) . '/' . substr($sha1, 2) . '.php';

        return $result;
    }
1269545
protected function toWords($number, $power = 0)
    {
        $return = '';

        if ($number < 0) {
            $return .= $this->minus;
            $number *= -1;
        }

        if (strlen($number) > 4) {
            $maxp = strlen($number) - 1;
            $curp = $maxp;

            for ($p = $maxp; $p > 0; --$p) { // power
                // check for highest power
                if (isset(self::$exponent[$p])) {
                    // send substr from $curp to $p
                    $snum = substr($number, $maxp - $curp, $curp - $p + 1);
                    $snum = preg_replace('/^0+/', '', $snum);
                    if ($snum !== '') {
                        $cursuffix = self::$exponent[$power][count(self::$exponent[$power]) - 1];

                        $return .= $this->toWords($snum, $p, $cursuffix);
                    }
                    $curp = $p - 1;
                    continue;
                }
            }
            $number = substr($number, $maxp - $curp, $curp - $p + 1);
            if ($number == 0) {
                return $return;
            }
        } elseif ($number == 0 || $number == '') {
            return $this->wordSeparator . self::$digits[0];
        }

        $h = $t = $d = $th = 0;

        switch (strlen($number)) {
            case 4:
                $th = (int) substr($number, -4, 1);

            case 3:
                $h = (int) substr($number, -3, 1);

            case 2:
                $t = (int) substr($number, -2, 1);

            case 1:
                $d = (int) substr($number, -1, 1);
                break;

            case 0:
                return;
                break;
        }

        if ($th) {
            if ($th == 1) {
                $return .= $this->wordSeparator . 'seribu';
            } else {
                $return .= $this->wordSeparator . self::$digits[$th] . $this->wordSeparator . 'ribu';
            }
        }

        if ($h) {
            if ($h == 1) {
                $return .= $this->wordSeparator . 'seratus';
            } else {
                $return .= $this->wordSeparator . self::$digits[$h] . $this->wordSeparator . 'ratus';
            }
        }

        // ten, twenty etc.
        switch ($t) {
            case 9:
            case 8:
            case 7:
            case 6:
            case 5:
            case 4:
            case 3:
            case 2:
                $return .= $this->wordSeparator . self::$digits[$t] . ' puluh';
                break;

            case 1:
                switch ($d) {
                    case 0:
                        $return .= $this->wordSeparator . 'sepuluh';
                        break;

                    case 1:
                        $return .= $this->wordSeparator . 'sebelas';
                        break;

                    case 2:
                    case 3:
                    case 4:
                    case 5:
                    case 6:
                    case 7:
                    case 8:
                    case 9:
                        $return .= $this->wordSeparator . self::$digits[$d] . ' belas';
                        break;
                }
                break;
        }

        if ($t != 1 && $d > 0) { // add digits only in <0>,<1,9> and <21,inf>
            // add minus sign between [2-9] and digit
            if ($t > 1) {
                $return .= ' ' . self::$digits[$d];
            } else {
                $return .= $this->wordSeparator . self::$digits[$d];
            }
        }

        if ($power > 0) {
            if (isset(self::$exponent[$power])) {
                $lev = self::$exponent[$power];
            }

            if (!isset($lev) || !is_array($lev)) {
                return null;
            }

            $return .= $this->wordSeparator . $lev[0];
        }

        return $return;
    }
777751
private function getFileNameForKey($key)
    {
        return $this->getDir().strtr($this->format, ['%key%' => $key, '%env%' => $this->environment]);
    }
118276
function findKey( $key )
    {
        $msg = null;
        if ( isset( $this->Messages[$key] ) )
        {
            $msg = $this->Messages[$key];
        }
        return $msg;
    }