JonathanTorres\Construct\Helpers\Str::toQuotedKeywords PHP Method

toQuotedKeywords() public method

Ex: "test,php,vagrant,provision" -> '"test","php","vagrant","provision"'
public toQuotedKeywords ( string $keywords ) : string
$keywords string
return string
    public function toQuotedKeywords($keywords)
    {
        if (trim($keywords) === '' || $keywords === null) {
            return '';
        }
        $keywordsQuoted = array_map(function ($keyword) {
            return '"' . trim($keyword) . '"';
        }, explode(',', $keywords));
        return implode(', ', $keywordsQuoted);
    }

Usage Example

Beispiel #1
0
 /**
  * Generate composer file.
  *
  * @param \JonathanTorres\Construct\Helpers\Git $git The git helper.
  *
  * @return void
  */
 protected function composer(Git $git)
 {
     $file = $this->file->get(__DIR__ . '/stubs/composer.txt');
     $user = $git->getUser();
     $stubs = ['{project_upper}', '{project_lower}', '{vendor_lower}', '{vendor_upper}', '{testing}', '{testing_version}', '{namespace}', '{license}', '{author_name}', '{author_email}', '{keywords}'];
     $values = [$this->projectUpper, $this->projectLower, $this->vendorLower, $this->vendorUpper, $this->settings->getTestingFramework(), $this->testingVersion, $this->createNamespace(true), $this->settings->getLicense(), $user['name'], $user['email'], $this->str->toQuotedKeywords($this->settings->getComposerKeywords())];
     $content = str_replace($stubs, $values, $file);
     $this->file->put($this->projectLower . '/' . 'composer.json', $content);
 }
All Usage Examples Of JonathanTorres\Construct\Helpers\Str::toQuotedKeywords