/** * @param array< * string $original what is being replaced * string $new what it is being replaced with * string $subject what contains the original> * $data * * @flo string after it has been replaced * * @return void */ public function __invoke($data) { lineOut(__METHOD__); // lineOut('data2:'); lineOut($data); // lineOut('style matches:'); lineOut($this->matches); # also str_replace any content in matches so that when it loops later we don't have old versions if one selector is replaced? $content = (string) $data['content']; // same as substring 1st position // [ ] need to do this a better way for ($i = 0; $i <= count($this->matches) / 2; $i++) { unset($this->matches[$i]); } if (!is_array($this->matches)) { $this->matches = array($this->matches); } foreach ($this->matches as $key => $match) { $replaced = $match; $replaced = str_replace('#' . $data['original'], '#' . $data['new'], $replaced); $replaced = str_replace('.' . $data['original'], '.' . $data['new'], $replaced); $content = str_replace($match, $replaced, $content); # should be [writeout]->WriteContent[in] $data['content']->setContent($content); $this->matches[$key] = $replaced; lineOut('replacing `' . $data['original'] . '` with `' . $data['new'] . '`'); lineOut('using the $match:'); lineOut($match); lineOut('result_of_replace_is:'); lineOut($replaced); } $this->sendThenDisconnect('out', $data['content']); }
public function __invoke() { lineOut(__METHOD__); $data = StaticContent::$content; // lineOut($data); $this->sendThenDisconnect('out', $data); }
public function mapInOut($map) { lineOut(__METHOD__); $this->sendThenDisconnect('map', $map, false); // if we have no content in attached, this is the end #if (!$this->inPorts['content']->isAttached()) {lineOut('content not attached');$this->sendIfAttached('out', $map);} }
/** * @param string $data * @out array<string|array<string>> matches * @return void */ public function outs($data) { lineOut(__CLASS__ . ".> " . static::class . " " . __METHOD__); $dataOut = $this->get($data); lineOut($dataOut); $this->sendThenDisconnect('out', $dataOut); }
public function __invoke($data) { lineOut(__METHOD__); lineOut('ReplaceMarkupClasses'); // lineOut('data:'); lineOut($data); lineOut('this content:'); lineOut($this->content); // (?:\s|\") #'/(?<=class\=)(?:\"|\')(?:[a-zA-Z0-9\s]*?)\b('.$data['original'].')\b(?=\"|\'|\s)/s', // could match them all, explode it, make a copy, replace it... $content = (string) $data['content']; preg_match_all('/(?<=class\\=\\")([a-zA-Z0-9-\\s]*)(?=\\")/s', $content, $matches); $matches = Arr::flatten($matches); $matchCopy = ""; // echo "CLEAN UP MATCH: ". __METHOD__; foreach ($matches as $match) { $matchesExploded = explode(" ", $match); foreach ($matchesExploded as $key => $subMatch) { $matchesExploded[$key] = str_replace($data['original'], $data['new'], $subMatch); } $matchesImploded = implode(" ", $matchesExploded); $content = str_replace($match, $matchesImploded, $content); } $data['content']->setContent($content); /* $data['content']->setContent(preg_replace( '/(?<=class\=)(?:\"|\')(?:[a-zA-Z0-9\s]*?)\b('.$data['original'].')\b(?:\"|\')(?:[a-zA-Z0-9\s]*?)(?=\"|\'|\s)/', $data['new'], $data['content'])); */ // $this->content = $data['content']; $this->sendIfAttached('out', $data['content']); }
/** * @example * pass in the originals * * @param array<string>|string $originalArray * @return void */ public function __invoke($originalArray) { lineOut(__METHOD__); foreach ((array) $originalArray as $original) { $this->originalToPlanck($original); } $this->outPorts['out']->send(OriginalAndPlanckMap::$map); }
public function __invoke($data) { lineOut(__METHOD__); $this->outPorts['regex']->send($data); $this->outPorts['content']->send($data); $this->outPorts['regex']->disconnect(); $this->outPorts['content']->disconnect(); $this->sendThenDisconnect('out', $data); }
/** * @param string $data * @return void */ public function output($data) { lineOut(__METHOD__); if (is_string($data)) { $data = explode($this->delimiter, $data); } $this->outPorts['out']->send($data); $this->outPorts['out']->disconnect(); }
public function __invoke($identityArray) { lineOut(__METHOD__); lineOut($identityArray); $identityArray = removeEmptyStringAndNullKeyAndValues($identityArray); lineOut("after useless removed"); lineOut($identityArray); $this->outPorts['out']->send($identityArray); $this->outPorts['out']->disconnect(); }
/** * @param string $data * @return void */ public function output($data) { lineOut(__METHOD__); if (is_array($data) || $data instanceof \Transversable) { $data = implode($this->delimiter, $data); } // lineOut($data); $this->outPorts['out']->send($data); $this->outPorts['out']->disconnect(); }
public function mapOut() { lineOut(__METHOD__); $contents = []; foreach ($this->originalToPlanckMap as $original => $planck) { $contents[] = $content = ['content' => $this->content, 'original' => $original, 'new' => $planck]; $this->sendIfAttached('identitiesout', $content); } $this->disconnectIfAttached('identitiesout'); }
/** * Aka: Repeat * @param string $content */ public function __invoke($content) { lineOut(__METHOD__ . ' ' . '(Repeat)'); // lineOut($content); $this->outPorts['contentout']->send(new Content($content)); $this->outPorts['contentout']->disconnect(); $this->outPorts['style']->send($content); $this->outPorts['style']->disconnect(); $this->outPorts['markup']->send($content); $this->outPorts['markup']->disconnect(); }
/** * @param array $data */ public function __invoke($data) { lineOut(__METHOD__); if (!is_array($data) && !$data instanceof \Transversable) { $this->sendIfAttached('error', "Argument `{$data}` is not an array or Transverable"); throw new InvalidArgumentException("Argument `{$data}` is not an array or Transverable"); } $arrayKeys = array_keys($data); $this->outPorts['out']->send($arrayKeys); $this->outPorts['out']->disconnect(); }
/** * @param array< * string $original what is being replaced * string $new what it is being replaced with * string $subject what contains the original * * @flo string after it has been replaced * * @return void */ public function __invoke($data) { lineOut(__METHOD__); lineOut(__METHOD__); lineOut('data:'); lineOut($data); lineOut('this content:'); lineOut($this->content); $data['content']->setContent(str_replace('id="' . $data['original'] . '"', 'id="' . $data['new'] . '"', $data['content'])); // $this->content = $data['content']; $this->sendIfAttached('out', $data['content']); }
/** * @param mixed $data * @return void */ public function output($data) { echo "<br><br><br><br><br><br><br><br><br><br><br><br><br>"; echo "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"; echo "<hr><hr><hr>"; lineOut(__METHOD__); echo "<h1>Original to Planck map</h1>"; lineOut($this->map); echo "<h1>Original content</h1>"; lineOut($this->originalContent); echo "<h1>Plancked content</h1>"; lineOut($this->planckedContent); }
/** * @param mixed $data * @return void */ public function output($data) { if (is_array($data)) { lineOut(__METHOD__); $dataString = Arr::flatten($data); $dataString = array_unique($dataString); $dataString = implode(",", $dataString); Emitter::emit('test.output', $dataString); lineOut($dataString); } lineOut(__METHOD__ . ' - original;'); lineOut($data); }
public function __invoke($identityArray) { lineOut(__METHOD__); // lineOut($identityArray); $identities = sortByKeyLength($identityArray); // lineOut($identities); if (!isAssociativeArray($identities)) { $identities = sortByLength($identityArray); } // lineOut($identities); $this->outPorts['out']->send($identities); $this->outPorts['out']->disconnect(); }
/** * @param mixed $data * @return void */ public function output($data) { lineOut(__METHOD__); if (is_object($data) && method_exists($data, '__toString')) { $data = $data->__toString(); } if (!is_string($data)) { $data = var_export($data, true); } $fileHandler = fopen($this->file, 'w+'); fwrite($fileHandler, $data); fclose($fileHandler); // lineOut($data); }
/** * @param mixed $data */ public function __invoke($data) { lineOut(__METHOD__); $this->outPorts['out']->send(json_decode($data, $this->asArray)); $this->outPorts['out']->disconnect(); }
public function setContent($content) { lineOut(static::class . " " . __METHOD__); $this->content = $content; }
public function __invoke($originalAndPlanckMap = null) { lineOut(__METHOD__); $this->sendThenDisconnect('out', OriginalAndPlanckMap::$map); }
/** * Initializes context. * Every scenario gets its own context object. * * @param array $params context params (behat.yml) */ public function __construct($params = []) { $this->networkFactory = new NetworkFactory(); $this->planckFactory = new PlanckFactory(); $adapter = new Local(__DIR__ . ''); $this->filesystem = new Filesystem($adapter); $this->memoryFilesystem = new Filesystem(new MemoryAdapter()); lineOut("\n<hr>___________________________________________________________________________"); OriginalAndPlanckMap::reset(); Plancks::reset(); $me = $this; Emitter::addListener('testing.output', function ($event, $param = null) use($me) { $me->output = $param; }); }
public function __invoke($data) { lineOut(__METHOD__); $content = (string) $data['content']; if (is_array($this->matches)) { for ($i = 0; $i <= count($this->matches) / 2; $i++) { unset($this->matches[$i]); } } if (!is_array($this->matches)) { $this->matches = array($this->matches); } foreach ($this->matches as $key => $match) { # with and without `.` & `#` #" match " #"match" #"match " // ([a-zA-Z0-9-\s]*) preg_match_all('/(?<=\'|")(.*?)(?=\'|\\")/', $match, $matches); // echo "MATCHES"; // dump($matches); $matches = $matches[1]; $matches = Arr::flatten($matches); $matchCopy = ""; foreach ($matches as $match2) { // if we remove the original, is there leftover? if so, it may be part of something else. // if (strlen(str_replace($data['original'], "", $match2))) // we do not want to replace it if there are letters or numbers or - or _ before or after it // we do want to replace it if any other character is right before or after it $originalLength = strlen($data['original']); // what we want to replace is longer than the match, not possible. if ($originalLength > strlen($match2)) { continue; } $positions = substringAll($match2, $data['original']); $disallowedChars = array_merge(range('a', 'z'), range('A', 'Z'), range('0', '9'), ['-', '_', '+']); // ECHO "<H1>LINEOUT</H1>"; // dump($positions); if (!empty($positions)) { foreach ($positions as $position) { // starting one character before, and going one character longer // ECHO "<H1>positionPlusMinusOnePos</H1>"; // dump($position); $startingPosition = $position === 0 ? $position : $position - 1; $positionPlusMinusOne = substr($match2, $startingPosition, $originalLength + 1); $endOfPositionMinusOne = substr($positionPlusMinusOne, -1); $endOfDataOriginal = substr($data['original'], -1); // they are the same length as the original or match, nothing different. // we know they are the same value, nothing different if (strlen($positionPlusMinusOne) === $originalLength && $positionPlusMinusOne === strlen($match2) && $data['original'] === $positionPlusMinusOne) { $replaced = str_replace($data['original'], $data['new'], $match2); $content = str_replace($match2, $replaced, $content); // $data['content']->setContent($content); //dump($data); continue; } /* ECHO "<H1>positionPlusMinusOne</H1>"; dump($positionPlusMinusOne); dump($data['original']); dump($originalLength + 1); dump($position); dump($startingPosition); dump($match2); dump($content); */ // we know the first char of both are not the same so we check if ($data['original'][0] !== $positionPlusMinusOne[0]) { if (containsAnySubStrings($positionPlusMinusOne[0], $disallowedChars)) { // ECHO "<H1>IT HAS SOME SHIT in [0]</H1>"; // dump($positionPlusMinusOne[0]); continue; } } if ($endOfDataOriginal !== $endOfPositionMinusOne) { if (containsAnySubStrings($endOfPositionMinusOne, $disallowedChars)) { // ECHO "<H1>IT HAS SOME SHIT in end</H1>"; // dump($endOfPositionMinusOne); continue; } } $replaced = str_replace($data['original'], $data['new'], $match2); $content = str_replace('"' . $match2 . '"', '"' . $replaced . '"', $content); $content = str_replace("'" . $match2 . "'", "'" . $replaced . "'", $content); $data['content']->setContent($content); // echo("<h3>JAVASCRIPT replaced: </h3>"); // dump($replaced); // dump($replaced); //dump($data); /* ECHO "<H1>positionPlusMinusOne</H1>"; dump($positionPlusMinusOne); dump($data['original']); dump($originalLength + 1); dump($position); dump($startingPosition); dump($match2); */ } } /*else { $replaced = str_replace($data['original'], $data['new'], $match2); $content = str_replace($match2, $replaced, $content); echo("<h3> elsed</h3>"); dump($data['original']); dump($data['new']); dump($match2); dump($replaced); dump($data); // dump($content); }*/ } $data['content']->setContent($content); // echo("<h3>JAVASCRIPT match: </h3>"); // dump($match2); // dump($data); } $this->sendIfAttached('out', $data['content']); }
public function addMatch($data) { lineOut(__METHOD__); // lineOut($data); $this->matches = array_merge((array) $data, $this->matches); }
public function __invoke($data) { lineOut(__METHOD__); $this->outPorts['styleblocks']->send($data); $this->outPorts['styleblocks']->disconnect(); }
/** * @param string $data * @return void */ public function call($data) { lineOut(__METHOD__); $callback = $this->callback; $callback($data); }
public function identities() { lineOut(__METHOD__); $this->outPorts['identitiesout0']->send($this->identities); parent::identities(); }
public function __invoke($originalsArray) { lineOut(__METHOD__); $this->debug($originalsArray); $this->outPorts['out']->send($originalsArray); }
public function outs() { lineOut(__METHOD__); $this->outPorts['classes']->disconnect(); $this->outPorts['identities']->disconnect(); }
/** * Aka: Repeat * @param string $content */ public function __invoke($content) { lineOut(__METHOD__); $this->sendThenDisconnect('replace', $content); $this->sendThenDisconnect('extract', (string) $content); }