How to use fromArray method of Comment class

Best Cucumber Common Library code snippet using Comment.fromArray

EntityItem.php

Source:EntityItem.php Github

copy

Full Screen

...27 return [28 'name' => $this->data['_className'],29 'namespacename' => $this->data['_namespace'] . '\Entity',30 'extendedclass' => $this->data['_namespace'] . '\Entity\Entity',31 'docblock' => DocBlockGenerator::fromArray(32 [33 'shortDescription' => 'Application Entity',34 'longDescription' => null,35 'tags' => [36 [37 'name' => 'package',38 'description' => $this->data['_namespace'],39 ],40 [41 'name' => 'author',42 'description' => $this->data['_author'],43 ],44 [45 'name' => 'copyright',46 'description' => $this->data['_copyright'],47 ],48 [49 'name' => 'license',50 'description' => $this->data['_license'],51 ],52 ],53 ]54 ),55 'properties' => $this->getProperties(),56 'methods' => $methods,57 ];58 }59 private function getProperties()60 {61 $classProperties = [];62 $classProperties[] = PropertyGenerator::fromArray(63 [64 'name' => 'primary_key',65 'defaultvalue' => 'array' !== $this->data['_primaryKey']['phptype'] ? $this->data['_primaryKey']['field'] : eval('return ' . $this->data['_primaryKey']['field'] . ';'),66 'flags' => PropertyGenerator::FLAG_PROTECTED,67 'docblock' => DocBlockGenerator::fromArray(68 [69 'shortDescription' => 'Primary key name',70 'longDescription' => '',71 'tags' => [72 new GenericTag('var', $this->data['_primaryKey']['phptype'] . ' primary_key'),73 ],74 ]75 ),76 ]77 );78 $classProperties[] = PropertyGenerator::fromArray(79 [80 'name' => 'isDoc',81 'defaultvalue' => false,82 'flags' => PropertyGenerator::FLAG_PROTECTED,83 'docblock' => DocBlockGenerator::fromArray(84 [85 'shortDescription' => 'Set Entity type',86 'longDescription' => '',87 'tags' => [88 new GenericTag('var', 'boolean isDoc'),89 ],90 ]91 ),92 ]93 );94 foreach ($this->data['_columns'] as $column) {95 $comment = !empty($column['comment']) ? $column['comment'] : null;96 $classProperties[] = PropertyGenerator::fromArray(97 [98 'name' => $column['capital'],99 'flags' => PropertyGenerator::FLAG_PROTECTED,100 'docblock' => DocBlockGenerator::fromArray(101 [102 'shortDescription' => $column['capital'],103 'longDescription' => $comment,104 'tags' => [105 new GenericTag('var', $column['phptype'] . ' ' . $column['capital']),106 ],107 ]108 ),109 ]110 );111 }112 foreach ($this->data['foreignKeysInfo'] as $key) {113 if (!is_array($key['column_name'])) {114 $name = $this->data['relationNameParent'][$key['key_name']] . $this->_getCapital(115 $key['column_name']116 );117 $classProperties[] = PropertyGenerator::fromArray(118 [119 'name' => $name,120 'flags' => PropertyGenerator::FLAG_PROTECTED,121 'docblock' => DocBlockGenerator::fromArray(122 [123 'shortDescription' => 'Parent relation',124 'longDescription' => null,125 'tags' => [126 new GenericTag('var', $this->data['className'][$key['key_name']]['foreign_tbl_name'] . ' ' . $name),127 ],128 ]129 ),130 ]131 );132 }133 }134 foreach ($this->data['dependentTables'] as $key) {135 $name = $this->data['relationNameDependent'][$key['key_name']];136 $longDescr = sprintf(137 'Type: %s relationship', ($key['type'] == 'one') ? 'One-to-One' : 'One-to-Many'138 );139 $classProperties[] = PropertyGenerator::fromArray(140 [141 'name' => $name,142 'flags' => PropertyGenerator::FLAG_PROTECTED,143 'docblock' => DocBlockGenerator::fromArray(144 [145 'shortDescription' => 'Dependent relation ',146 'longDescription' => $longDescr,147 'tags' => [148 new GenericTag('var', $this->data['classNameDependent'][$key['key_name']]['foreign_tbl_name'] . ' ' . $name),149 ],150 ]151 ),152 ]153 );154 }155 return $classProperties;156 }157 private function getConstructor()158 {159 $constructBody = '$this->setColumnsList(array(' . PHP_EOL;160 foreach ($this->data['_columns'] as $column) {161 $constructBody .= ' \'' . $column['field'] . '\' => \'' . $column['capital'] . '\',' . PHP_EOL;162 }163 $constructBody .= '));' . PHP_EOL;164 $constructBody .= '$this->setParentList(array(' . PHP_EOL;165 foreach ($this->data['foreignKeysInfo'] as $key) {166 if (is_array($key['column_name'])) {167 $n = [];168 foreach ($key['column_name'] as $v) {169 $n[] = '\'' . $this->data['relationNameParent'][$key['key_name']] . $this->_getCapital($v) . '\'';170 }171 $property = ' array(' . implode(',', $n) . ')';172 } else {173 $property = '\'' . $this->data['relationNameParent'][$key['key_name']] . $this->_getCapital($key['column_name']) . '\'';174 }175 $constructBody .= ' \'' . $this->_getCapital($key['key_name']) . '\' => array(' . PHP_EOL;176 $constructBody .= ' \'property\' => ' . $property . ',' . PHP_EOL;177 $constructBody .= ' \'table_name\' => \'' . $this->data['className'][$key['key_name']]['foreign_tbl_name'] . '\',' . PHP_EOL;178 $constructBody .= ' ),' . PHP_EOL;179 }180 $constructBody .= '));' . PHP_EOL;181 $constructBody .= '$this->setDependentList(array(' . PHP_EOL;182 foreach ($this->data['dependentTables'] as $key) {183 $name = $this->data['relationNameDependent'][$key['key_name']];184 $constructBody .= ' \'' . $this->_getCapital($key['key_name']) . '\' => array(' . PHP_EOL;185 $constructBody .= ' \'property\' => \'' . $name . '\',' . PHP_EOL;186 $constructBody .= ' \'table_name\' => \'' . $this->data['classNameDependent'][$key['key_name']]['foreign_tbl_name'] . '\',' . PHP_EOL;187 $constructBody .= ' ),' . PHP_EOL;188 }189 $constructBody .= '));' . PHP_EOL;190 $methods = [191 [192 'name' => '__construct',193 'parameters' => [],194 'flags' => MethodGenerator::FLAG_PUBLIC,195 'body' => $constructBody,196 'docblock' => DocBlockGenerator::fromArray(197 [198 'shortDescription' => 'Sets up column and relationship lists',199 'longDescription' => null,200 ]201 ),202 ],203 ];204 return $methods;205 }206 private function getAccessor()207 {208 $methods = [];209 foreach ($this->data['_columns'] as $column) {210 $is_date = strpos($column['type'], 'datetime') === false && strpos($column['type'], 'timestamp') === false;211 $comment = 'Sets column ' . $column['field'];212 $comment .= $is_date ? '' : ' Stored in \'Y-m-d H:i:s\' format .';213 $constructBody = '';214 if (!$is_date) {215 $constructBody .= 'if (! empty($data)) {' . PHP_EOL;216 $constructBody .= ' if ($data instanceof \MongoDB\BSON\UTCDateTime) {' . PHP_EOL;217 $constructBody .= ' $data = $data->toDateTime();' . PHP_EOL;218 $constructBody .= ' }' . PHP_EOL;219 $constructBody .= ' if (! $data instanceof \DateTime) {' . PHP_EOL;220 $constructBody .= ' $data = new \DateTime($data);' . PHP_EOL;221 $constructBody .= ' }' . PHP_EOL;222 $constructBody .= ' $data = $data->format(\'Y-m-d H:i:s\');' . PHP_EOL;223 $constructBody .= '}' . PHP_EOL;224 }225 $constructBody .= '$this->' . $column['capital'] . ' = $data;' . PHP_EOL;226 $constructBody .= 'return $this;' . PHP_EOL;227 $methods[] = MethodGenerator::fromArray([228 'name' => 'set' . $column['capital'],229 'parameters' => ['data'],230 'flags' => MethodGenerator::FLAG_PUBLIC,231 'body' => $constructBody,232 'docblock' => DocBlockGenerator::fromArray(233 [234 'shortDescription' => $comment,235 'longDescription' => null,236 'tags' => [237 new ParamTag('data', $column['phptype'], $column['field']),238 new ReturnTag([239 'datatype' => 'self',240 ]),241 ],242 ]243 ),244 ]);245 $comment = 'Gets column ' . $column['field'];246 $comment .= $is_date ? '' : ' Stored in \'Y-m-d H:i:s\' format .';247 $constructBody = '';248 $parameters = [];249 $returnType = $column['phptype'];250 $tags = [251 new ReturnTag([252 'datatype' => $returnType,253 ]),254 ];255 if (!$is_date) {256 $parameters = [257 ParameterGenerator::fromArray(258 [259 'type' => 'bool',260 'name' => 'returnDateTime',261 'defaultvalue' => false,262 ]263 ),264 ];265 array_unshift($tags, new ParamTag('returnDateTime', ['boolean'], 'Should we return a DateTime object'));266 $constructBody .= 'if ($returnDateTime) {' . PHP_EOL;267 $constructBody .= ' if ($this->' . $column['capital'] . ' === null) {' . PHP_EOL;268 $constructBody .= ' return null;' . PHP_EOL;269 $constructBody .= ' }' . PHP_EOL;270 $constructBody .= ' return new \DateTime($this->' . $column['capital'] . ');' . PHP_EOL;271 $constructBody .= '}' . PHP_EOL;272 if ($this->data['db-type'] == 'mongodb') {273 $constructBody .= 'if ($this->isDoc && $this->' . $column['capital'] . '){' . PHP_EOL;274 $constructBody .= ' return new \MongoDB\BSON\UTCDateTime((new \DateTime($this->' . $column['capital'] . '))->getTimestamp() * 1000);' . PHP_EOL;275 $constructBody .= '}' . PHP_EOL;276 }277 $constructBody .= 'return $this->' . $column['capital'] . ';' . PHP_EOL;278 } elseif ($column['phptype'] == 'boolean') {279 $constructBody .= 'return $this->' . $column['capital'] . ' ? true : false;' . PHP_EOL;280 } else {281 if ($this->data['db-type'] == 'mongodb') {282 $constructBody .= 'if (!empty($this->' . $column['capital'] . ')){' . PHP_EOL;283 if ($column['primary']) {284 $constructBody .= ' if ($this->' . $column['capital'] . ' instanceof \MongoDB\BSON\ObjectId){' . PHP_EOL;285 $constructBody .= ' return $this->' . $column['capital'] . ';' . PHP_EOL;286 $constructBody .= ' } else {' . PHP_EOL;287 $constructBody .= ' return (' . $returnType . ')$this->' . $column['capital'] . ';' . PHP_EOL;288 $constructBody .= ' }' . PHP_EOL;289 } else {290 $constructBody .= 'if ($this->isDoc && $this->' . $column['capital'] . ' instanceof \MongoDB\BSON\ObjectId){' . PHP_EOL;291 $constructBody .= ' return $this->' . $column['capital'] . ';' . PHP_EOL;292 $constructBody .= '}' . PHP_EOL;293 $constructBody .= ' return (' . $returnType . ')$this->' . $column['capital'] . ';' . PHP_EOL;294 }295 $constructBody .= '}' . PHP_EOL;296 $constructBody .= 'return $this->' . $column['capital'] . ';' . PHP_EOL;297 } else {298 $constructBody .= 'return !empty($this->' . $column['capital'] . ') ? (' . $returnType . ')$this->' . $column['capital'] . ' : $this->' . $column['capital'] . ';' . PHP_EOL;299 }300 }301 $methods[] = MethodGenerator::fromArray([302 'name' => 'get' . $column['capital'],303 'parameters' => $parameters,304 'flags' => MethodGenerator::FLAG_PUBLIC,305 'body' => $constructBody,306 'docblock' => DocBlockGenerator::fromArray(307 [308 'shortDescription' => $comment,309 'longDescription' => null,310 'tags' => $tags,311 ]312 ),313 ]);314 }315 return $methods;316 }317 private function getParentRelation()318 {319 $methods = [];320 foreach ($this->data['foreignKeysInfo'] as $key) {321 if (is_array($key['column_name'])) {322 continue;323 }324 $comment = 'Sets parent relation ' . $this->data['className'][$key['key_name']]['column_name'];325 $constructBody = '';326 $constructBody .= '$this->' . $this->data['relationNameParent'][$key['key_name']] . $this->_getCapital(327 $key['column_name']328 ) . ' = $data;' . PHP_EOL;329 $constructBody .= '$primary_key = $data->getPrimaryKey();' . PHP_EOL;330 $constructBody .= '$dataValue = $data->toArray();' . PHP_EOL;331 if (is_array($key['foreign_tbl_column_name']) && is_array($key['column_name'])) {332 while ($column = next($key['foreign_tbl_column_name'])) {333 $foreign_column = next($key['column_name']);334 $constructBody .= '$this->set' . $this->_getCapital(335 $column336 ) . '($primary_key[\'' . $foreign_column . '\']);' . PHP_EOL;337 }338 } else {339 /*340 $constructBody .= 'if (is_array($primary_key)) {' . PHP_EOL;341 $constructBody .= ' $primary_key = $primary_key[\'' . $key['foreign_tbl_column_name'] . '\'];' . PHP_EOL;342 $constructBody .= '}' . PHP_EOL;343 */344 $constructBody .= '$this->set' . $this->_getCapital($key['column_name']) . '($dataValue[$primary_key]);' . PHP_EOL;345 }346 $constructBody .= 'return $this;' . PHP_EOL;347 $methods[] = [348 'name' => 'set' . $this->data['relationNameParent'][$key['key_name']] . $this->_getCapital(349 $key['column_name']350 ),351 'parameters' => [352 ParameterGenerator::fromArray(353 [354 'name' => 'data',355 'type' => $this->data['_namespace'] . '\Entity\\' . $this->data['className'][$key['key_name']]['foreign_tbl_name'],356 ]357 ),358 ],359 'flags' => MethodGenerator::FLAG_PUBLIC,360 'body' => $constructBody,361 'docblock' => DocBlockGenerator::fromArray(362 [363 'shortDescription' => $comment,364 'longDescription' => null,365 'tags' => [366 new ParamTag('data', [$this->data['_namespace'] . '\Entity\\' . $this->data['className'][$key['key_name']]['foreign_tbl_name']]),367 new ReturnTag(['datatype' => 'self']),368 ],369 ]370 ),371 ];372 $comment = 'Gets parent ' . $this->data['className'][$key['key_name']]['column_name'];373 $constructBody = '';374 $constructBody .= 'return $this->' . $this->data['relationNameParent'][$key['key_name']] . $this->_getCapital(375 $key['column_name']376 ) . ';' . PHP_EOL;377 $methods[] = [378 'name' => 'get' . $this->data['relationNameParent'][$key['key_name']] . $this->_getCapital(379 $key['column_name']380 ),381 'parameters' => [],382 'flags' => MethodGenerator::FLAG_PUBLIC,383 'body' => $constructBody,384 'docblock' => DocBlockGenerator::fromArray(385 [386 'shortDescription' => $comment,387 'longDescription' => null,388 'tags' => [389 new ReturnTag(['datatype' => $this->data['className'][$key['key_name']]['foreign_tbl_name']]),390 ],391 ]392 ),393 ];394 }395 return $methods;396 }397 private function getDependentTables()398 {399 $methods = [];400 foreach ($this->data['dependentTables'] as $key) {401 if ($key['type'] == 'one') {402 $comment = 'Sets dependent relation ' . $key['key_name'];403 $constructBody = '';404 $constructBody .= '$this->' . $this->data['relationNameDependent'][$key['key_name']] . ' = $data;' . PHP_EOL;405 $constructBody .= 'return $this;' . PHP_EOL;406 $methods[] = [407 'name' => 'set' . $this->data['relationNameDependent'][$key['key_name']],408 'parameters' => [409 ParameterGenerator::fromArray(410 [411 'name' => 'data',412 'type' => $this->data['classNameDependent'][$key['key_name']]['foreign_tbl_name'],413 ]414 ),415 ],416 'flags' => MethodGenerator::FLAG_PUBLIC,417 'body' => $constructBody,418 'docblock' => DocBlockGenerator::fromArray(419 [420 'shortDescription' => $comment,421 'longDescription' => null,422 'tags' => [423 new ParamTag('data', [$this->data['classNameDependent'][$key['key_name']]['foreign_tbl_name']]),424 new ReturnTag(['datatype' => 'self']),425 ],426 ]427 ),428 ];429 $comment = 'Gets dependent ' . $key['key_name'];430 $constructBody = '';431 $constructBody .= 'return $this->' . $this->data['relationNameDependent'][$key['key_name']] . ';' . PHP_EOL;432 $methods[] = [433 'name' => 'get' . $this->data['relationNameDependent'][$key['key_name']],434 'parameters' => [],435 'flags' => MethodGenerator::FLAG_PUBLIC,436 'body' => $constructBody,437 'docblock' => DocBlockGenerator::fromArray(438 [439 'shortDescription' => $comment,440 'longDescription' => null,441 'tags' => [442 new ReturnTag([$this->data['classNameDependent'][$key['key_name']]['foreign_tbl_name']]),443 ],444 ]445 ),446 ];447 } else {448 $comment = 'Sets dependent relation ' . $key['key_name'];449 $constructBody = '';450 $constructBody .= 'foreach ($data as $object) {' . PHP_EOL;451 $constructBody .= ' $this->add' . $this->data['relationNameDependent'][$key['key_name']] . '($object);' . PHP_EOL;452 $constructBody .= '}' . PHP_EOL;453 $constructBody .= 'return $this;' . PHP_EOL;454 $methods[] = [455 'name' => 'set' . $this->data['relationNameDependent'][$key['key_name']],456 'parameters' => [457 ParameterGenerator::fromArray(458 [459 'name' => 'data',460 'type' => 'array',461 ]462 ),463 ],464 'flags' => MethodGenerator::FLAG_PUBLIC,465 'body' => $constructBody,466 'docblock' => DocBlockGenerator::fromArray(467 [468 'shortDescription' => $comment,469 'longDescription' => null,470 'tags' => [471 new ParamTag('data', ['array'], ' array of ' . $this->data['classNameDependent'][$key['key_name']]['foreign_tbl_name']),472 new ReturnTag(['datatype' => 'self']),473 ],474 ]475 ),476 ];477 $comment = 'Gets dependent ' . $key['key_name'];478 $constructBody = '';479 $constructBody .= 'return $this->' . $this->data['relationNameDependent'][$key['key_name']] . ';' . PHP_EOL;480 $methods[] = [481 'name' => 'get' . $this->data['relationNameDependent'][$key['key_name']],482 'parameters' => [],483 'flags' => MethodGenerator::FLAG_PUBLIC,484 'body' => $constructBody,485 'docblock' => DocBlockGenerator::fromArray(486 [487 'shortDescription' => $comment,488 'longDescription' => null,489 'tags' => [490 new ReturnTag(['datatype' => 'array'], 'array of ' . $this->data['classNameDependent'][$key['key_name']]['foreign_tbl_name']),491 ],492 ]493 ),494 ];495 $comment = 'Sets dependent relations ' . $key['key_name'];496 $constructBody = '';497 $constructBody .= '$this->' . $this->data['relationNameDependent'][$key['key_name']] . '[] = $data;' . PHP_EOL;498 $constructBody .= 'return $this;' . PHP_EOL;499 $methods[] = [500 'name' => 'add' . $this->data['relationNameDependent'][$key['key_name']],501 'parameters' => [502 ParameterGenerator::fromArray(503 [504 'name' => 'data',505 ]506 ),507 ],508 'flags' => MethodGenerator::FLAG_PUBLIC,509 'body' => $constructBody,510 'docblock' => DocBlockGenerator::fromArray(511 [512 'shortDescription' => $comment,513 'longDescription' => null,514 'tags' => [515 new ParamTag('data', [$this->data['classNameDependent'][$key['key_name']]['foreign_tbl_name']], $comment),516 new ReturnTag(['datatype' => 'self']),517 ],518 ]519 ),520 ];521 }522 }523 return $methods;524 }525 private function getUtils()526 {527 $constructBody = '';528 foreach ($this->data['_columns'] as $column) {529 $is_date = strpos($column['type'], 'datetime') !== false || strpos($column['type'], 'timestamp') !== false;530 if ($is_date) {531 $constructBody .= '$this->set' . $column['capital'] . '(isset($data[\'' . $column['field'] . '\']) ? $data[\'' . $column['field'] . '\'] : null);' . PHP_EOL;532 } else {533 $constructBody .= '$this->' . $column['capital'] . ' = isset($data[\'' . $column['field'] . '\']) ? $data[\'' . $column['field'] . '\'] : null;' . PHP_EOL;534 }535 }536 $constructBody .= 'return $this;';537 $methods[] = MethodGenerator::fromArray([538 'name' => 'exchangeArray',539 // 'returntype' => $this->data['_namespace'] . '\Entity\\' . $this->data['_className'],540 'parameters' => [541 ParameterGenerator::fromArray(542 [543 'name' => 'data',544 'type' => 'array',545 ]546 ),547 ],548 'flags' => MethodGenerator::FLAG_PUBLIC,549 'body' => $constructBody,550 'docblock' => DocBlockGenerator::fromArray(551 [552 'shortDescription' => 'Array of options/values to be set for this model.',553 'longDescription' => 'Options without a matching method are ignored.',554 'tags' => [555 new ParamTag('data', ['array'], 'array of values to set'),556 new ReturnTag(['datatype' => 'self']),557 ],558 ]559 ),560 ]);561 $constructBody = '$this->isDoc = $val;' . PHP_EOL;562 $constructBody .= 'return $this;' . PHP_EOL;563 $methods[] = MethodGenerator::fromArray([564 'name' => 'setIsDoc',565 'parameters' => [566 ParameterGenerator::fromArray(567 [568 'name' => 'val',569 'type' => 'bool',570 'defaultvalue' => true,571 ]572 ),573 ],574 // 'returntype' => 'self',575 'flags' => MethodGenerator::FLAG_PUBLIC,576 'body' => $constructBody,577 'docblock' => DocBlockGenerator::fromArray(578 [579 'shortDescription' => 'Set type of entity',580 'longDescription' => null,581 'tags' => [582 new ParamTag('val', ['boolean']),583 ],584 ]585 ),586 ]);587 $constructBody = '';588 $constructBody .= '$result = array(' . PHP_EOL;589 foreach ($this->data['_columns'] as $column) {590 $constructBody .= ' \'' . $column['field'] . '\' => $this->get' . $column['capital'] . '(),' . PHP_EOL;591 }592 $constructBody .= ');' . PHP_EOL;593 $constructBody .= 'return $result;' . PHP_EOL;594 $methods[] = MethodGenerator::fromArray([595 'name' => 'toArray',596 'parameters' => [],597 'returntype' => 'array',598 'flags' => MethodGenerator::FLAG_PUBLIC,599 'body' => $constructBody,600 'docblock' => DocBlockGenerator::fromArray(601 [602 'shortDescription' => 'Returns an array, keys are the field names.',603 'longDescription' => null,604 'tags' => [605 new ReturnTag(['datatype' => 'array']),606 ],607 ]608 ),609 ]);610 return $methods;611 }612 /**613 *614 * @return string615 */616 public function generate()617 {618 $class = ClassGenerator::fromArray($this->getClassArrayRepresentation());619 $class->addUse($this->data['_namespace'] . '\Entity\Entity');620 $this->defineFileInfo($class);621 $fileGenerator = $this->getFileGenerator();622 return $fileGenerator623 ->setClass($class)624 ->generate();625 }626}...

Full Screen

Full Screen

Issue.php

Source:Issue.php Github

copy

Full Screen

...44 * @param Project $project45 * @param array $data46 * @return Issue47 */48 public static function fromArray(Client $client, Project $project, array $data)49 {50 $issue = new static($project, $data['iid'], $client);51 if (isset($data['author'])) {52 $data['author'] = User::fromArray($client, $data['author']);53 }54 if (isset($data['assignee'])) {55 $data['assignee'] = User::fromArray($client, $data['assignee']);56 }57 return $issue->hydrate($data);58 }59 /**60 * @param Project $project61 * @param int $iid62 * @param Client $client63 */64 public function __construct(Project $project, $iid = null, Client $client = null)65 {66 $this->setClient($client);67 $this->setData('project', $project);68 $this->setData('iid', $iid);69 }70 /**71 * @return Issue72 */73 public function show()74 {75 $data = $this->client->issues()->show($this->project->id, $this->iid);76 return static::fromArray($this->getClient(), $this->project, $data);77 }78 /**79 * @param array $params80 * @return Issue81 */82 public function update(array $params)83 {84 $data = $this->client->issues()->update($this->project->id, $this->iid, $params);85 return static::fromArray($this->getClient(), $this->project, $data);86 }87 /**88 * @param Project $toProject89 * @return Issue90 */91 public function move(Project $toProject)92 {93 $data = $this->client->issues()->move($this->project->id, $this->iid, $toProject->id);94 return static::fromArray($this->getClient(), $toProject, $data);95 }96 /**97 * @param string $comment98 * @return Issue99 */100 public function close($comment = null)101 {102 if ($comment) {103 $this->addComment($comment);104 }105 return $this->update(array(106 'state_event' => 'close'107 ));108 }109 /**110 * @return Issue111 */112 public function open()113 {114 return $this->update(array(115 'state_event' => 'reopen'116 ));117 }118 /**119 * @return Issue120 */121 public function reopen()122 {123 return $this->open();124 }125 /**126 * @param string $comment127 * @return Note128 */129 public function addComment($comment)130 {131 $data = $this->client->issues()->addComment($this->project->id, $this->iid, array(132 'body' => $comment133 ));134 return Note::fromArray($this->getClient(), $this, $data);135 }136 /**137 * @return Note[]138 */139 public function showComments()140 {141 $notes = array();142 $data = $this->client->issues()->showComments($this->project->id, $this->iid);143 foreach ($data as $note) {144 $notes[] = Note::fromArray($this->getClient(), $this, $note);145 }146 return $notes;147 }148 /**149 * @return bool150 */151 public function isClosed()152 {153 return $this->state === 'closed';154 }155 /**156 * @param string $label157 * @return bool158 */159 public function hasLabel($label)160 {161 return in_array($label, $this->labels);162 }163 /**164 * @return IssueLink[]165 */166 public function links()167 {168 $data = $this->client->issueLinks()->all($this->project->id, $this->iid);169 if (!is_array($data)) {170 return array();171 }172 $projects = $this->client->projects();173 return array_map(function ($data) use ($projects) {174 return IssueLink::fromArray(175 $this->client,176 Project::fromArray($this->client, $projects->show($data['project_id'])),177 $data178 );179 }, $data);180 }181 /**182 * @param Issue $target183 * @return Issue[]184 */185 public function addLink(Issue $target)186 {187 $data = $this->client->issueLinks()->create($this->project->id, $this->iid, $target->project->id, $target->iid);188 if (!is_array($data)) {189 return array();190 }191 return [192 'source_issue' => static::fromArray($this->client, $this->project, $data['source_issue']),193 'target_issue' => static::fromArray($this->client, $target->project, $data['target_issue']),194 ];195 }196 /**197 * @param int $issue_link_id198 * @return Issue[]199 */200 public function removeLink($issue_link_id)201 {202 // The two related issues have the same link ID.203 $data = $this->client->issueLinks()->remove($this->project->id, $this->iid, $issue_link_id);204 if (!is_array($data)) {205 return array();206 }207 $targetProject = Project::fromArray(208 $this->client,209 $this->client->projects()->show($data['target_issue']['project_id'])210 );211 return [212 'source_issue' => static::fromArray($this->client, $this->project, $data['source_issue']),213 'target_issue' => static::fromArray($this->client, $targetProject, $data['target_issue']),214 ];215 }216}...

Full Screen

Full Screen

MergeRequest.php

Source:MergeRequest.php Github

copy

Full Screen

...56 * @param Project $project57 * @param array $data58 * @return MergeRequest59 */60 public static function fromArray(Client $client, Project $project, array $data)61 {62 $mr = new static($project, $data['id'], $client);63 if (isset($data['author'])) {64 $data['author'] = User::fromArray($client, $data['author']);65 }66 if (isset($data['assignee'])) {67 $data['assignee'] = User::fromArray($client, $data['assignee']);68 }69 if (isset($data['milestone'])) {70 $data['milestone'] = Milestone::fromArray($client, $project, $data['milestone']);71 }72 if (isset($data['files'])) {73 $files = array();74 foreach ($data['files'] as $file) {75 $files[] = File::fromArray($client, $project, $file);76 }77 $data['files'] = $files;78 }79 return $mr->hydrate($data);80 }81 /**82 * @param Project $project83 * @param int $iid84 * @param Client $client85 */86 public function __construct(Project $project, $iid = null, Client $client = null)87 {88 $this->setClient($client);89 $this->setData('project', $project);90 $this->setData('iid', $iid);91 }92 /**93 * @return MergeRequest94 */95 public function show()96 {97 $data = $this->client->mergeRequests()->show($this->project->id, $this->iid);98 return static::fromArray($this->getClient(), $this->project, $data);99 }100 /**101 * @param array $params102 * @return MergeRequest103 */104 public function update(array $params)105 {106 $data = $this->client->mergeRequests()->update($this->project->id, $this->iid, $params);107 return static::fromArray($this->getClient(), $this->project, $data);108 }109 /**110 * @param string $comment111 * @return MergeRequest112 */113 public function close($comment = null)114 {115 if ($comment) {116 $this->addComment($comment);117 }118 return $this->update(array(119 'state_event' => 'close'120 ));121 }122 /**123 * @return MergeRequest124 */125 public function reopen()126 {127 return $this->update(array(128 'state_event' => 'reopen'129 ));130 }131 /**132 * @return MergeRequest133 */134 public function open()135 {136 return $this->reopen();137 }138 /**139 * @param string $message140 * @return MergeRequest141 */142 public function merge($message = null)143 {144 $data = $this->client->mergeRequests()->merge($this->project->id, $this->iid, array(145 'merge_commit_message' => $message146 ));147 return static::fromArray($this->getClient(), $this->project, $data);148 }149 /**150 * @return MergeRequest151 */152 public function merged()153 {154 return $this->update(array(155 'state_event' => 'merge'156 ));157 }158 /**159 * @param string $comment160 * @return Note161 */162 public function addComment($comment)163 {164 $data = $this->client->mergeRequests()->addComment($this->project->id, $this->iid, $comment);165 return Note::fromArray($this->getClient(), $this, $data);166 }167 /**168 * @return Note[]169 */170 public function showComments()171 {172 $notes = array();173 $data = $this->client->mergeRequests()->showComments($this->project->id, $this->iid);174 foreach ($data as $note) {175 $notes[] = Note::fromArray($this->getClient(), $this, $note);176 }177 return $notes;178 }179 /**180 * @return bool181 */182 public function isClosed()183 {184 if (in_array($this->state, array('closed', 'merged'))) {185 return true;186 }187 return false;188 }189 /**190 * @return MergeRequest191 */192 public function changes()193 {194 $data = $this->client->mergeRequests()->changes($this->project->id, $this->iid);195 return static::fromArray($this->getClient(), $this->project, $data);196 }197}...

Full Screen

Full Screen

fromArray

Using AI Code Generation

copy

Full Screen

1$comment = new Comment();2$comment->fromArray($_POST);3$comment->save();4$comment = new Comment();5$comment->fromArray($_POST);6$comment->save();7$comment = new Comment();8$comment->fromArray($_POST);9$comment->save();10$comment = new Comment();11$comment->fromArray($_POST);12$comment->save();13$comment = new Comment();14$comment->fromArray($_POST);15$comment->save();16$comment = new Comment();17$comment->fromArray($_POST);18$comment->save();19$comment = new Comment();20$comment->fromArray($_POST);21$comment->save();22$comment = new Comment();23$comment->fromArray($_POST);24$comment->save();25$comment = new Comment();26$comment->fromArray($_POST);27$comment->save();28$comment = new Comment();29$comment->fromArray($_POST);30$comment->save();31$comment = new Comment();32$comment->fromArray($_POST);33$comment->save();34$comment = new Comment();35$comment->fromArray($_POST);36$comment->save();37$comment = new Comment();38$comment->fromArray($_POST);39$comment->save();40$comment = new Comment();41$comment->fromArray($_POST);

Full Screen

Full Screen

fromArray

Using AI Code Generation

copy

Full Screen

1$comment = new Comment();2$comment->fromArray($commentData);3$comment = new Comment();4$comment->fromArray($commentData);5$comment = new Comment();6$comment->fromArray($commentData);7$comment = new Comment();8$comment->fromArray($commentData);9$comment = new Comment();10$comment->fromArray($commentData);11$comment = new Comment();12$comment->fromArray($commentData);13$comment = new Comment();14$comment->fromArray($commentData);15$comment = new Comment();16$comment->fromArray($commentData);17$comment = new Comment();18$comment->fromArray($commentData);19$comment = new Comment();20$comment->fromArray($commentData);21$comment = new Comment();22$comment->fromArray($commentData);23$comment = new Comment();24$comment->fromArray($commentData);25$comment = new Comment();26$comment->fromArray($commentData);27$comment = new Comment();28$comment->fromArray($commentData);29$comment = new Comment();30$comment->fromArray($commentData);

Full Screen

Full Screen

fromArray

Using AI Code Generation

copy

Full Screen

1$comment = new Comment();2$comment->fromArray($data);3$post = new Post();4$post->fromArray($data);5$user = new User();6$user->fromArray($data);7$comment = new Comment();8$comment->fromArray($data);9$post = new Post();10$post->fromArray($data);11$user = new User();12$user->fromArray($data);13$comment = new Comment();14$comment->fromArray($data);15$post = new Post();16$post->fromArray($data);17$user = new User();18$user->fromArray($data);19$comment = new Comment();20$comment->fromArray($data);21$post = new Post();22$post->fromArray($data);23$user = new User();24$user->fromArray($data);25$comment = new Comment();26$comment->fromArray($data);27$post = new Post();28$post->fromArray($data);29$user = new User();30$user->fromArray($data);31$comment = new Comment();32$comment->fromArray($data);33$post = new Post();34$post->fromArray($data);35$user = new User();36$user->fromArray($data);37$comment = new Comment();38$comment->fromArray($data);39$post = new Post();

Full Screen

Full Screen

fromArray

Using AI Code Generation

copy

Full Screen

1$comment = new Comment();2$comment->fromArray($_POST);3$post = new Post();4$post->fromArray($_POST);5$comment = new Comment();6$comment->fromArray($_POST);7$post = new Post();8$post->fromArray($_POST);9$comment = new Comment();10$comment->fromArray($_POST);11$post = new Post();12$post->fromArray($_POST);13$comment = new Comment();14$comment->fromArray($_POST);15$post = new Post();16$post->fromArray($_POST);17$comment = new Comment();18$comment->fromArray($_POST);19$post = new Post();20$post->fromArray($_POST);21$comment = new Comment();22$comment->fromArray($_POST);23$post = new Post();24$post->fromArray($_POST);25$comment = new Comment();26$comment->fromArray($_POST);27$post = new Post();28$post->fromArray($_POST);29$comment = new Comment();30$comment->fromArray($_POST);31$post = new Post();32$post->fromArray($_POST);33$comment = new Comment();34$comment->fromArray($_POST);35$post = new Post();36$post->fromArray($_POST);

Full Screen

Full Screen

fromArray

Using AI Code Generation

copy

Full Screen

1$comment = new Comment();2$comment->fromArray(array(3));4$comment->save();5$comment = new Comment();6$comment->title = 'my title';7$comment->content = 'my content';8$comment->author = 'my author';9$comment->date = '2015-04-10';10$comment->save();11$commentArray = $comment->toArray();12print_r($commentArray);13$comment = new Comment();14$comment->title = 'my title';15$comment->content = 'my content';16$comment->author = 'my author';17$comment->date = '2015-04-10';18$comment->save();19$comment->title = 'my new title';20$comment->update();

Full Screen

Full Screen

fromArray

Using AI Code Generation

copy

Full Screen

1$comment = new Comment();2$comment->fromArray($_POST);3echo $comment->getComment();4$comment = new Comment();5$comment->fromArray($_POST);6echo $comment->getComment();7$comment = new Comment();8$comment->fromArray($_POST);9echo $comment->getComment();10$comment = new Comment();11$comment->fromArray($_POST);12echo $comment->getComment();13$comment = new Comment();14$comment->fromArray($_POST);15echo $comment->getComment();16$comment = new Comment();17$comment->fromArray($_POST);18echo $comment->getComment();19$comment = new Comment();20$comment->fromArray($_POST);21echo $comment->getComment();22$comment = new Comment();23$comment->fromArray($_POST);24echo $comment->getComment();25$comment = new Comment();26$comment->fromArray($_POST);27echo $comment->getComment();28$comment = new Comment();29$comment->fromArray($_POST);30echo $comment->getComment();31$comment = new Comment();32$comment->fromArray($_POST);33echo $comment->getComment();

Full Screen

Full Screen

fromArray

Using AI Code Generation

copy

Full Screen

1$comment = new Comment();2$comment->fromArray($_POST);3$comment->save();4$comment = new Comment();5$comment->fromArray($_POST);6$comment->save();7$comment = new Comment();8$comment->fromArray($_POST);9$comment->save();10$comment = new Comment();11$comment->fromArray($_POST);12$comment->save();13$comment = new Comment();14$comment->fromArray($_POST);15$comment->save();16$comment = new Comment();17$comment->fromArray($_POST);18$comment->save();19$comment = new Comment();20$comment->fromArray($_POST);21$comment->save();22$comment = new Comment();23$comment->fromArray($_POST);24$comment->save();25$comment = new Comment();26$comment->fromArray($_POST);27$comment->save();28$comment = new Comment();29$comment->fromArray($_POST);30$comment->save();31$comment = new Comment();32$comment->fromArray($_POST);33$comment->save();34$comment = new Comment();35$comment->fromArray($_POST);36$comment->save();37$comment = new Comment();38$comment->fromArray($_POST);39$comment->save();40$comment = new Comment();

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Cucumber Common Library automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in Comment

Trigger fromArray code on LambdaTest Cloud Grid

Execute automation tests with fromArray on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful