Skip to content
Snippets Groups Projects
Commit 6b64c57e authored by ArturoDelMadrazo's avatar ArturoDelMadrazo
Browse files

Ajout faker

parent 6f39a228
No related branches found
No related tags found
No related merge requests found
Pipeline #10913 failed
<?php
class Faker
{
private array $code = ['Filter a array and exclude element if key is "chapeau"', 'Check if word is a palindromic word', 'return a number of occurence for word into a text'];
private array $test = ["If you're using JavaScript, you can use the filter method to exclude elements with a key of 'chapeau'. Here's an example:",
"A palindromic word is a word that reads the same backward as forward. To check if a word is a palindromic word, you can compare its reverse to the original word. Here's an example in JavaScript:",
"To return the number of occurrences of a word in a text, you can use the split method to convert the text into an array of words, and then use the filter method to count the number of elements in the array that match the target word. Here's an example in JavaScript:"];
public int $number;
public function __construct()
{
$this->number = rand(0, sizeof($this->code)-1);
}
public function getCode(): string
{
return $this->code[$this->number];
}
public function getTest(): string
{
return $this->test[$this->number];
}
public function regenerateCode(): void
{
$this->number = rand(1, sizeof($this->code));
}
}
\ No newline at end of file
<?php
require_once('Faker.php');
class OPenAIGenerator
{
private string $question;
......@@ -12,6 +13,11 @@ class OPenAIGenerator
{
$this->usefaker = $useFaker;
$this->question = $question;
if($useFaker)
{
$fakerClasse = new Faker();
$this->setFaker($fakerClasse);
}
if($generateCode)
{
$this->code = $this->genCode();
......@@ -19,10 +25,10 @@ class OPenAIGenerator
$this->test = $this->genTest();
}
public function setFaker($faker) // SPECIFY CLASS OF FAKER FOR RETURN TYPE
public function setFaker($fakerClasse) // SPECIFY CLASS OF FAKER FOR RETURN TYPE
{
// TO DOO SET FAKER CLASSE
$this->faker = $faker;
$this->faker = $fakerClasse;
}
public function genCode(): string
......@@ -42,7 +48,7 @@ class OPenAIGenerator
{
// TO DOO
// USE CLASS FAKER FOR RETURN STRING
return "";
return $this->faker->getCode();
}
}
......@@ -63,7 +69,7 @@ class OPenAIGenerator
{
// TO DOO
// USE CLASS FAKER FOR RETURN STRING
return "";
return $this->faker->getTest();
}
}
......
......@@ -21,7 +21,7 @@ HTMLEOF;
if(!empty($_POST['question']))
{
$gen = new OpenAIGenerator($_POST['question']);
$gen = new OpenAIGenerator($_POST['question'], true ,true);
echo $gen;
}
else
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment