Save a key to a file

@param Key|KeyPair $key
@param string $filename
@return bool
@throws \TypeError
16786
public static function save($key, string $filename = ''): bool
    {
        if ($key instanceof KeyPair) {
            return self::saveKeyFile(
                $filename,
                $key->getSecretKey()->getRawKeyMaterial()
            );
        }
        return self::saveKeyFile($filename, $key->getRawKeyMaterial());
    }
1362422
public function save($key, $data)
	{
		$hash = md5($key);
		$cacheFile = $this->getPath().'/'.$hash.'.cache';

		return file_put_contents($cacheFile, serialize($data));
	}
623671
public function save($filename)
    {
        $type = pathinfo($filename, PATHINFO_EXTENSION);
        $type = ($type === 'jpg') ? 'jpeg' : $type;
        $type = (in_array($type, $this->imageTypes)) ? $type : 'png';

        header('Content-type: image/' . $type);

        $imageFunc = 'image' . $type;
        $imageFunc($this->image, $filename);

        $this->destroy($this->image);

        return $this;
    }
138093
protected function makeFile($key, $file)
    {
        return $this->finder->put($this->getDestinationFile($file), $this->getStubContent($key));
    }
403803
public function generateKey($key, $fileName = null)
    {
        if ($key) {
            $key = $this->chiper->encrypt($key);
        }

        return parent::generateKey($key, $fileName);
    }
594052
private function saveKeyToFile($key)
    {
        $tmpDir = sys_get_temp_dir();
        $keyPath = $tmpDir . '/' . sha1($key) . '.key';

        if (file_exists($keyPath)) {
            return 'file://' . $keyPath;
        }

        if (!touch($keyPath)) {
            // @codeCoverageIgnoreStart
            throw new RuntimeException(sprintf('"%s" key file could not be created', $keyPath));
            // @codeCoverageIgnoreEnd
        }

        if (file_put_contents($keyPath, $key) === false) {
            // @codeCoverageIgnoreStart
            throw new RuntimeException(sprintf('Unable to write key file to temporary directory "%s"', $tmpDir));
            // @codeCoverageIgnoreEnd
        }

        if (chmod($keyPath, 0600) === false) {
            // @codeCoverageIgnoreStart
            throw new RuntimeException(sprintf('The key file "%s" file mode could not be changed with chmod to 600', $keyPath));
            // @codeCoverageIgnoreEnd
        }

        return 'file://' . $keyPath;
    }
1227380
public function save($path = null, $filename = null) {
        $path = $path ?: storage_path();
        $filename = $filename ?: $this->getName();

        $path = substr($path, -1) == DIRECTORY_SEPARATOR ? $path : $path.DIRECTORY_SEPARATOR;

        return File::put($path.$filename, $this->getContent()) !== false;
    }
430348
public function SaveFile($Key, $Index = 0, $TargetPath = '')
	{
		if (!isset($this->Data[$Key]))
		{
			return false;
		}
		if (!isset($this->Data[$Key][$Index]))
		{
			return false;
		}

		// Returing false if it is an image URL
		if (stripos($this->Data[$Key][$Index]['Value'], 'uri:') === 0)
		{
			return false;
		}

		if (is_writable($TargetPath) || (!file_exists($TargetPath) && is_writable(dirname($TargetPath))))
		{
			$RawContent = $this->Data[$Key][$Index]['Value'];
			if (isset($this->Data[$Key][$Index]['Encoding']) && $this->Data[$Key][$Index]['Encoding'] == 'b')
			{
				$RawContent = base64_decode($RawContent);
			}
			$Status = file_put_contents($TargetPath, $RawContent);
			return (bool)$Status;
		}
		else
		{
			throw new Exception('vCard: Cannot save file ('.$Key.'), target path not writable ('.$TargetPath.')');
		}
		return false;
	}
1139240
public function Sign($cert_filename, $key_filename, $key_pass) {
    $this->sign_cert_file = $cert_filename;
    $this->sign_key_file = $key_filename;
    $this->sign_key_pass = $key_pass;
  }
827537
protected function saveInCache($filename, $content)
    {
        if (empty($this->cacheDir) || ! is_dir($this->cacheDir) || ! is_writable($this->cacheDir)) {
            return false;
        }

        $content["_chk"] = filemtime($filename);

        file_put_contents(
            $this->cacheDir . DIRECTORY_SEPARATOR . basename($filename) . ".cache",
            "<?php return " . var_export($content, true) . ";"
        );

        return true;
    }
796104
public String saveAs(String streamKey, String fileName) throws QiniuException {
        return saveAs(streamKey, fileName, 0, 0);
    }
1007556
protected function prepare_write( $key ) {
		if ( ! $this->enabled ) {
			return false;
		}

		$filename = $this->filename( $key );

		if ( ! $this->ensure_dir_exists( dirname( $filename ) ) ) {
			return false;
		}

		return $filename;
	}
270771
public function removeKey($fileName, $key)
    {
        foreach ($this->languages() as $language) {
            $filePath = $this->path."/{$language}/{$fileName}.php";

            $fileContent = $this->getFileContent($filePath);

            Arr::forget($fileContent, $key);

            $this->writeFile($filePath, $fileContent);
        }
    }
304930
public function save($fileName = null)
	{
		file_put_contents(empty($fileName) ? $this->fileName : $fileName, '<?php return ' . var_export($this->data, true) . ';', LOCK_EX);
	}
323364
public function saveInCache($key, $value)
  {
    $this->deleteFromCache($key);
    $file = $this->cachePath . $this->getEncodedKey($key);
    file_put_contents($file, serialize($value), LOCK_EX);
  }
1205503
public function save($filename)
    {
        $fp = @fopen($filename, 'w+b');
        if (!is_resource($fp)) {
            throw new WavFileException('Failed to open "' . $filename . '" for writing.');
        }

        fwrite($fp, $this->makeHeader());
        fwrite($fp, $this->getDataSubchunk());
        fclose($fp);

        return $this;
    }
70315
public function put($key, $data)
    {
        $filename = $this->getKeyCode($key);
        $data = json_encode($data);
        $this->write($data, $filename);
    }