Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,10 @@
"psr-4": {
"Krlove\\CodeGenerator\\": "src/"
}
}
}
},
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
}
}
11 changes: 6 additions & 5 deletions src/Model/ArgumentModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ArgumentModel extends RenderableModel
* ArgumentModel constructor.
* @param string $name
* @param string|null $type
* @param mixed|null $default
* @param mixed|null $default used "as is"
*/
public function __construct($name, $type = null, $default = null)
{
Expand All @@ -43,11 +43,12 @@ public function __construct($name, $type = null, $default = null)
*/
public function toLines()
{
if ($this->type !== null) {
return $this->type . ' $' . $this->name;
} else {
if ($this->default !== null) {
return ltrim($this->type?:'' . ' $' . $this->name. ' = ' .$this->default);
} else {
return '$' . $this->name;
}
return ltrim($this->type?:'' . ' $' . $this->name);
}
}

/**
Expand Down
34 changes: 32 additions & 2 deletions src/Model/UseClassModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,32 @@ class UseClassModel extends RenderableModel
* @var string
*/
protected $name;
/**
* @var string
*/
protected $alias=null;

/**
* PHPClassUse constructor.
* @param string $name
*/
public function __construct($name)
public function __construct($name,$alias=null)
{
$this->name = $name;
if ($alias) $this->alias=$alias;
}

/**
* {@inheritDoc}
*/
public function toLines()
{
return sprintf('use %s;', $this->name);
if (is_null($this->alias)) {
return sprintf('use %s;', $this->name);
}
else {
return sprintf('use %s as %s;', $this->name,$this->alias);
}
}

/**
Expand All @@ -40,6 +50,14 @@ public function getName()
return $this->name;
}

/**
* @return string
*/
public function getAlias()
{
return $this->alias;
}

/**
* @param string $name
*
Expand All @@ -51,4 +69,16 @@ public function setName($name)

return $this;
}

/**
* @param string $alias
*
* @return $this
*/
public function setAlias($alias)
{
$this->alias = $alias;

return $this;
}
}