How to use SourceReference class

Best Cucumber Common Library code snippet using SourceReference

UpdateReferences.php

Source:UpdateReferences.php Github

copy

Full Screen

1<?php2namespace App\Console\Commands;3use App\Models\Continent;4use App\Models\Dxcc;5use App\Models\Program;6use App\Models\Reference;7use Grimzy\LaravelMysqlSpatial\Types\Point;8use Illuminate\Console\Command;9use Illuminate\Support\Facades\Artisan;10use Illuminate\Support\Facades\Http;11use Illuminate\Support\Str;12use League\Csv\Reader;13class UpdateReferences extends Command14{15 /**16 * The name and signature of the console command.17 *18 * @var string19 */20 protected $signature = 'update:references';21 /**22 * The console command description.23 *24 * @var string25 */26 protected $description = 'Fetched the CSV containing the WWFF references and updates them to database';27 /**28 * Create a new command instance.29 *30 * @return void31 */32 public function __construct()33 {34 parent::__construct();35 }36 /**37 * Execute the console command.38 *39 * @return int40 */41 public function handle()42 {43 // Download CSV44 $csv = Http::get('http://wwff.co/wwff-data/wwff_directory.csv');45 $reader = Reader::createFromString($csv);46 $reader->setHeaderOffset(0);47 $references = collect($reader->getRecords());48 // Filter out other than OHFF49 $references = $references->filter(function ($reference, $key) {50 return $reference['program'] === 'OHFF';51 });52 // Create progress bar53 $bar = $this->output->createProgressBar($references->count());54 $bar->setFormat('very_verbose');55 $bar->start();56 // Create / update programs57 $references->pluck('program')->unique()->each(function ($program) {58 Program::firstOrCreate(['name' => $program]);59 });60 // Create / update dxcc's61 $references->pluck('dxcc')->unique()->each(function ($dxcc) {62 Dxcc::firstOrCreate(['name' => $dxcc]);63 });64 // Create / update continents65 $references->pluck('continent')->unique()->each(function ($continent) {66 Continent::firstOrCreate(['name' => $continent]);67 });68 // Create / update references69 $references->each(function ($sourceReference) use ($bar) {70 // Replace empty and '-' values with null71 $sourceReference = array_map(function ($value) {72 return ($value === "" || $value === '-') ? null : $value;73 }, $sourceReference);74 // Check if we can parse Protected Planet ID from website75 $protectedPlanetId = null;76 77 if (Str::contains($sourceReference['website'], 'protectedplanet')) {78 $chunks = explode('/', $sourceReference['website']);79 $lastPart = end($chunks);80 $protectedPlanetId = (is_numeric($lastPart)) ? $lastPart : null;81 }82 // Create or update reference83 $reference = Reference::updateOrCreate(['reference' => $sourceReference['reference']], [84 'name' => $sourceReference['name'],85 'status' => $sourceReference['status'],86 'iota_reference' => $sourceReference['iota'],87 'wdpa_id' => $protectedPlanetId,88 ]);89 // Set or update location if changed. This is so that the model does not appear dirty unnecessarily.90 if (is_null($reference->location) || ($reference->location->getLat() !== floatval($sourceReference['latitude']) || $reference->location->getLng() !== floatval($sourceReference['longitude']))) {91 $reference->location = new Point($sourceReference['latitude'], $sourceReference['longitude']);92 }93 // Add relations94 $program = Program::where('name', $sourceReference['program'])->firstOrFail();95 $reference->program()->associate($program);96 $dxcc = Dxcc::where('name', $sourceReference['dxcc'])->first();97 $reference->dxcc()->associate($dxcc);98 $continent = Continent::where('name', $sourceReference['continent'])->first();99 $reference->continent()->associate($continent);100 $reference->save();101 $bar->advance();102 });103 $bar->finish();104 // Clear the response cache105 Artisan::call('responsecache:clear');106 // Warm up cache107 Http::get('https://kartta.ohff.fi/geojson');108 Http::get('https://kartta.ohff.fi/geojson?filter%5Bactivated_by%5D=&filter%5Bnot_activated_by%5D=&filter%5Breference%5D=');109 return 0;110 }111}...

Full Screen

Full Screen

Hook.php

Source:Hook.php Github

copy

Full Screen

...20 */21 public function __construct(22 public readonly string $id = '',23 public readonly ?string $name = null,24 public readonly SourceReference $sourceReference = new SourceReference(),25 public readonly ?string $tagExpression = null,26 ) {27 }28 /**29 * @throws SchemaViolationException30 *31 * @internal32 */33 public static function fromArray(array $arr): self34 {35 self::ensureId($arr);36 self::ensureName($arr);37 self::ensureSourceReference($arr);38 self::ensureTagExpression($arr);39 return new self(40 (string) $arr['id'],41 isset($arr['name']) ? (string) $arr['name'] : null,42 SourceReference::fromArray($arr['sourceReference']),43 isset($arr['tagExpression']) ? (string) $arr['tagExpression'] : null,44 );45 }46 /**47 * @psalm-assert array{id: string|int|bool} $arr48 */49 private static function ensureId(array $arr): void50 {51 if (!array_key_exists('id', $arr)) {52 throw new SchemaViolationException('Property \'id\' is required but was not found');53 }54 if (array_key_exists('id', $arr) && is_array($arr['id'])) {55 throw new SchemaViolationException('Property \'id\' was array');56 }57 }58 /**59 * @psalm-assert array{name?: string|int|bool} $arr60 */61 private static function ensureName(array $arr): void62 {63 if (array_key_exists('name', $arr) && is_array($arr['name'])) {64 throw new SchemaViolationException('Property \'name\' was array');65 }66 }67 /**68 * @psalm-assert array{sourceReference: array} $arr69 */70 private static function ensureSourceReference(array $arr): void71 {72 if (!array_key_exists('sourceReference', $arr)) {73 throw new SchemaViolationException('Property \'sourceReference\' is required but was not found');74 }75 if (array_key_exists('sourceReference', $arr) && !is_array($arr['sourceReference'])) {76 throw new SchemaViolationException('Property \'sourceReference\' was not array');77 }78 }79 /**80 * @psalm-assert array{tagExpression?: string|int|bool} $arr81 */82 private static function ensureTagExpression(array $arr): void83 {84 if (array_key_exists('tagExpression', $arr) && is_array($arr['tagExpression'])) {...

Full Screen

Full Screen

StepDefinition.php

Source:StepDefinition.php Github

copy

Full Screen

...20 */21 public function __construct(22 public readonly string $id = '',23 public readonly StepDefinitionPattern $pattern = new StepDefinitionPattern(),24 public readonly SourceReference $sourceReference = new SourceReference(),25 ) {26 }27 /**28 * @throws SchemaViolationException29 *30 * @internal31 */32 public static function fromArray(array $arr): self33 {34 self::ensureId($arr);35 self::ensurePattern($arr);36 self::ensureSourceReference($arr);37 return new self(38 (string) $arr['id'],39 StepDefinitionPattern::fromArray($arr['pattern']),40 SourceReference::fromArray($arr['sourceReference']),41 );42 }43 /**44 * @psalm-assert array{id: string|int|bool} $arr45 */46 private static function ensureId(array $arr): void47 {48 if (!array_key_exists('id', $arr)) {49 throw new SchemaViolationException('Property \'id\' is required but was not found');50 }51 if (array_key_exists('id', $arr) && is_array($arr['id'])) {52 throw new SchemaViolationException('Property \'id\' was array');53 }54 }55 /**56 * @psalm-assert array{pattern: array} $arr57 */58 private static function ensurePattern(array $arr): void59 {60 if (!array_key_exists('pattern', $arr)) {61 throw new SchemaViolationException('Property \'pattern\' is required but was not found');62 }63 if (array_key_exists('pattern', $arr) && !is_array($arr['pattern'])) {64 throw new SchemaViolationException('Property \'pattern\' was not array');65 }66 }67 /**68 * @psalm-assert array{sourceReference: array} $arr69 */70 private static function ensureSourceReference(array $arr): void71 {72 if (!array_key_exists('sourceReference', $arr)) {73 throw new SchemaViolationException('Property \'sourceReference\' is required but was not found');74 }75 if (array_key_exists('sourceReference', $arr) && !is_array($arr['sourceReference'])) {76 throw new SchemaViolationException('Property \'sourceReference\' was not array');77 }78 }79}...

Full Screen

Full Screen

SourceReference

Using AI Code Generation

copy

Full Screen

1require_once 'Cucumber/Common/SourceReference.php';2require_once 'Cucumber/Common/SourceReference/SourceFile.php';3require_once 'Cucumber/Common/SourceReference/SourceFile/Line.php';4require_once 'Cucumber/Common/SourceReference/SourceFile/Line/Part.php';5require_once 'Cucumber/Common/SourceReference/SourceFile/Line/Part/Token.php';6require_once 'Cucumber/Common/SourceReference/SourceFile/Line/Part/Token/Type.php';7$sourceReference = new Cucumber_Common_SourceReference(8 new Cucumber_Common_SourceReference_SourceFile(9 new Cucumber_Common_SourceReference_SourceFile_Line(10 new Cucumber_Common_SourceReference_SourceFile_Line_Part(11 new Cucumber_Common_SourceReference_SourceFile_Line_Part_Token(12);13echo $sourceReference->getLine()->getPart()->getToken()->getValue();14require_once 'Cucumber/Common/SourceReference.php';15require_once 'Cucumber/Common/SourceReference/SourceFile.php';16require_once 'Cucumber/Common/SourceReference/SourceFile/Line.php';17require_once 'Cucumber/Common/SourceReference/SourceFile/Line/Part.php';18require_once 'Cucumber/Common/SourceReference/SourceFile/Line/Part/Token.php';19require_once 'Cucumber/Common/SourceReference/SourceFile/Line/Part/Token/Type.php';20$sourceReference = new Cucumber_Common_SourceReference(21 new Cucumber_Common_SourceReference_SourceFile(22 new Cucumber_Common_SourceReference_SourceFile_Line(23 new Cucumber_Common_SourceReference_SourceFile_Line_Part(24 new Cucumber_Common_SourceReference_SourceFile_Line_Part_Token(25);

Full Screen

Full Screen

SourceReference

Using AI Code Generation

copy

Full Screen

1require_once 'Cucumber/Common/SourceReference.php';2$sourceReference = new Cucumber\Common\SourceReference();3$sourceReference->setSourceFile('2.php');4$sourceReference->setSourceLine(1);5require_once 'Cucumber/Common/SourceReference.php';6$sourceReference = new Cucumber\Common\SourceReference();7$sourceReference->setSourceFile('3.php');8$sourceReference->setSourceLine(1);9require_once 'Cucumber/Common/SourceReference.php';10$sourceReference = new Cucumber\Common\SourceReference();11$sourceReference->setSourceFile('4.php');12$sourceReference->setSourceLine(1);13require_once 'Cucumber/Common/SourceReference.php';14$sourceReference = new Cucumber\Common\SourceReference();15$sourceReference->setSourceFile('5.php');16$sourceReference->setSourceLine(1);17require_once 'Cucumber/Common/SourceReference.php';18$sourceReference = new Cucumber\Common\SourceReference();19$sourceReference->setSourceFile('6.php');20$sourceReference->setSourceLine(1);21require_once 'Cucumber/Common/SourceReference.php';22$sourceReference = new Cucumber\Common\SourceReference();23$sourceReference->setSourceFile('7.php');24$sourceReference->setSourceLine(1);25require_once 'Cucumber/Common/SourceReference.php';26$sourceReference = new Cucumber\Common\SourceReference();27$sourceReference->setSourceFile('8.php');28$sourceReference->setSourceLine(1);29require_once 'Cucumber/Common/SourceReference.php';30$sourceReference = new Cucumber\Common\SourceReference();31$sourceReference->setSourceFile('9.php');32$sourceReference->setSourceLine(1);

Full Screen

Full Screen

SourceReference

Using AI Code Generation

copy

Full Screen

1use Cucumber\Common\SourceReference;2$source = new SourceReference('1.php', 5);3$source->getLine();4$source->getFile();5$source->getRelativeFile();6$source->getSnippet();7$source->getSnippetText();8$source->getSnippetHtml();9$source->getSnippetHtmlWithLine();10$source->getSnippetHtmlWithLineAndFile();11$source->getSnippetHtmlWithLineAndFileAndLink();12$source->getSnippetHtmlWithLineAndFileAndLinkAndLinkText();13$source->getSnippetHtmlWithLineAndFileAndLinkAndLinkTextAndLinkTarget();14$source->getSnippetHtmlWithLineAndFileAndLinkAndLinkTextAndLinkTargetAndLinkClass();15$source->getSnippetHtmlWithLineAndFileAndLinkAndLinkTextAndLinkTargetAndLinkClassAndLinkId();16$source->getSnippetHtmlWithLineAndFileAndLinkAndLinkTextAndLinkTargetAndLinkClassAndLinkIdAndLinkTitle();17$source->getSnippetHtmlWithLineAndFileAndLinkAndLinkTextAndLinkTargetAndLinkClassAndLinkIdAndLinkTitleAndLinkRel();18$source->getSnippetHtmlWithLineAndFileAndLinkAndLinkTextAndLinkTargetAndLinkClassAndLinkIdAndLinkTitleAndLinkRelAndLinkStyle();

Full Screen

Full Screen

SourceReference

Using AI Code Generation

copy

Full Screen

1$source_reference = new SourceReference();2$source_reference->setSourceReference('1.php');3$source_reference->setSourceReference('3.php');4$source_reference->setSourceReference('4.php');5$source_reference->setSourceReference('5.php');6$source_reference->setSourceReference('6.php');7$source_reference->setSourceReference('7.php');8$source_reference->setSourceReference('8.php');9$source_reference->setSourceReference('9.php');10$source_reference->setSourceReference('10.php');11$source_reference->setSourceReference('11.php');12$source_reference->setSourceReference('12.php');13$source_reference->setSourceReference('13.php');14$source_reference->setSourceReference('14.php');15$source_reference->setSourceReference('15.php');16$source_reference->setSourceReference('16.php');17$source_reference->setSourceReference('17.php');18$source_reference->setSourceReference('18.php');19$source_reference->setSourceReference('19.php');20$source_reference->setSourceReference('20.php');21$source_reference->setSourceReference('21.php');22$source_reference->setSourceReference('22.php');23$source_reference->setSourceReference('23.php');24$source_reference->setSourceReference('24.php');25$source_reference->setSourceReference('25.php');26$source_reference->setSourceReference('26.php');27$source_reference->setSourceReference('27.php');28$source_reference->setSourceReference('28.php');29$source_reference->setSourceReference('29.php');30$source_reference->setSourceReference('30.php');31$source_reference->setSourceReference('31.php');32$source_reference->setSourceReference('32.php');33$source_reference->setSourceReference('33.php');34$source_reference->setSourceReference('34.php');35$source_reference->setSourceReference('35.php');36$source_reference->setSourceReference('36.php');37$source_reference->setSourceReference('37.php');38$source_reference->setSourceReference('38.php');39$source_reference->setSourceReference('39.php');40$source_reference->setSourceReference('40.php');41$source_reference->setSourceReference('41.php');42$source_reference->setSourceReference('42.php');43$source_reference->setSourceReference('43.php');44$source_reference->setSourceReference('44.php');

Full Screen

Full Screen

SourceReference

Using AI Code Generation

copy

Full Screen

1$src = new SourceReference();2$src->setSource("2.php");3$src->setSourceLine(1);4$src->setSourceColumn(1);5$src->setSourceLength(1);6$src->setSourceSnippet("2.php");7$src->setSourceFile("2.php");8$src->setSourceUri("2.php");9$src->setSourceUriBase("2.php");10$src->setSourceUriFragment("2.php");

Full Screen

Full Screen

SourceReference

Using AI Code Generation

copy

Full Screen

1$sr = new SourceReference();2$sr->setSource('2.php');3$sr->setLine(2);4throw new Exception($sr->getSourceReference());5PHP 1. {main}() 2.php:06PHP 2. Exception->__construct() 2.php:57PHP 3. Exception->getMessage() 2.php:08$sr = new SourceReference();9$sr->setSource('3.php');10$sr->setLine(2);11throw new Exception($sr->getSourceReference());12PHP 1. {main}() 3.php:013PHP 2. Exception->__construct() 3.php:514PHP 3. Exception->getMessage() 3.php:0

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.

Run Selenium Automation Tests on LambdaTest Cloud Grid

Trigger Selenium automation tests on a cloud-based Grid of 3000+ real browsers and operating systems.

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