modifs.mineures sans commentaires
This commit is contained in:
		
							parent
							
								
									15a5e7805f
								
							
						
					
					
						commit
						104da4515b
					
				@ -20,9 +20,23 @@ class CapacitorChannel {
 | 
			
		||||
 | 
			
		||||
  const EACH_COMMIT_THRESHOLD = 100;
 | 
			
		||||
 | 
			
		||||
  static function verifix_name(?string $name): string {
 | 
			
		||||
    if ($name === null) $name = "default";
 | 
			
		||||
    return strtolower($name);
 | 
			
		||||
  static function verifix_name(?string &$name, ?string &$tableName=null): void {
 | 
			
		||||
    if ($name !== null) {
 | 
			
		||||
      $name = strtolower($name);
 | 
			
		||||
      if ($tableName === null) $tableName = "${name}_channel";
 | 
			
		||||
    } else {
 | 
			
		||||
      $name = static::class;
 | 
			
		||||
      if ($name === self::class) {
 | 
			
		||||
        $name = "default";
 | 
			
		||||
        if ($tableName === null) $tableName = "default_channel";
 | 
			
		||||
      } else {
 | 
			
		||||
        $name = preg_replace('/^.*\\\\/', "", $name);
 | 
			
		||||
        $name = preg_replace('/Channel$/', "", $name);
 | 
			
		||||
        $name = lcfirst($name);
 | 
			
		||||
        if ($tableName === null) $tableName = str::camel2us($name);
 | 
			
		||||
        $name = strtolower($name);
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  protected static function verifix_eachCommitThreshold(?int $eachCommitThreshold): ?int {
 | 
			
		||||
@ -32,8 +46,11 @@ class CapacitorChannel {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  function __construct(?string $name=null, ?int $eachCommitThreshold=null, ?bool $manageTransactions=null) {
 | 
			
		||||
    $this->name = self::verifix_name($name ?? static::NAME);
 | 
			
		||||
    $this->tableName = static::TABLE_NAME ?? ($this->name."_channel");
 | 
			
		||||
    $name ??= static::NAME;
 | 
			
		||||
    $tableName ??= static::TABLE_NAME;
 | 
			
		||||
    self::verifix_name($name, $tableName);
 | 
			
		||||
    $this->name = $name;
 | 
			
		||||
    $this->tableName = $tableName;
 | 
			
		||||
    $this->manageTransactions = $manageTransactions ?? static::MANAGE_TRANSACTIONS;
 | 
			
		||||
    $this->eachCommitThreshold = self::verifix_eachCommitThreshold($eachCommitThreshold);
 | 
			
		||||
    $this->setup = false;
 | 
			
		||||
 | 
			
		||||
@ -22,7 +22,7 @@ abstract class CapacitorStorage {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  protected function getChannel(?string $name): CapacitorChannel {
 | 
			
		||||
    $name = CapacitorChannel::verifix_name($name);
 | 
			
		||||
    CapacitorChannel::verifix_name($name);
 | 
			
		||||
    $channel = $this->channels[$name] ?? null;
 | 
			
		||||
    if ($channel === null) {
 | 
			
		||||
      $channel = $this->addChannel(new CapacitorChannel($name));
 | 
			
		||||
 | 
			
		||||
@ -162,7 +162,7 @@ class Stream extends AbstractIterator implements IReader, IWriter {
 | 
			
		||||
 | 
			
		||||
  const DEFAULT_CSV_FLAVOUR = ref_csv::OO_FLAVOUR;
 | 
			
		||||
 | 
			
		||||
  /** @var array paramètres pour la lecture et l'écriture de flux au format CSV */
 | 
			
		||||
  /** @var string paramètres pour la lecture et l'écriture de flux au format CSV */
 | 
			
		||||
  protected $csvFlavour;
 | 
			
		||||
 | 
			
		||||
  function setCsvFlavour(?string $flavour): void {
 | 
			
		||||
@ -315,6 +315,11 @@ class Stream extends AbstractIterator implements IReader, IWriter {
 | 
			
		||||
    return unserialize(...$args);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  function decodeJson(bool $close=true, bool $alreadyLocked=false) {
 | 
			
		||||
    $contents = $this->getContents($close, $alreadyLocked);
 | 
			
		||||
    return json_decode($contents, true, 512, JSON_THROW_ON_ERROR);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  #############################################################################
 | 
			
		||||
  # Iterator
 | 
			
		||||
 | 
			
		||||
@ -456,6 +461,11 @@ class Stream extends AbstractIterator implements IReader, IWriter {
 | 
			
		||||
    $this->putContents(serialize($object), $close, $alreadyLocked);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  function encodeJson($data, bool $close=true, bool $alreadyLocked=false): void {
 | 
			
		||||
    $contents = json_encode($data, JSON_UNESCAPED_SLASHES + JSON_UNESCAPED_UNICODE);
 | 
			
		||||
    $this->putContents($contents, $close, $alreadyLocked);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * annuler une tentative d'écriture commencée avec {@link self::canWrite()}
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user