phpcs phpcbf

This commit is contained in:
2026-01-23 18:36:15 -08:00
parent c249151eb4
commit ae5fa27b7d
42 changed files with 82022 additions and 82113 deletions

View File

@@ -4,19 +4,10 @@ declare(strict_types=1);
namespace CakeAddresses\Model\Table;
use ArrayObject;
use Cake\Datasource\EntityInterface;
use Cake\Datasource\ResultSetInterface;
use Cake\Event\EventInterface;
use Cake\Log\Log;
use Cake\ORM\Association\BelongsTo;
use Cake\ORM\Query\SelectQuery;
use Cake\ORM\RulesChecker;
use Cake\ORM\Table;
use Cake\Validation\Validator;
use CakeAddresses\Model\Entity\Address;
use CakeAddresses\Model\Entity\State;
use Closure;
use Psr\SimpleCache\CacheInterface;
/**
* Addresses Model
@@ -25,176 +16,173 @@ use Psr\SimpleCache\CacheInterface;
* @property StatesTable&BelongsTo $States
* @property CountriesTable&BelongsTo $Countries
*
* @method Address newEmptyEntity()
* @method Address newEntity(array $data, array $options = [])
* @method \CakeAddresses\Model\Entity\Address newEmptyEntity()
* @method \CakeAddresses\Model\Entity\Address newEntity()
* @method array<Address> newEntities(array $data, array $options = [])
* @method Address get(mixed $primaryKey, array|string $finder = 'all', CacheInterface|string|null $cache = null, Closure|string|null $cacheKey = null, mixed ...$args)
* @method Address findOrCreate($search, ?callable $callback = null, array $options = [])
* @method Address patchEntity(EntityInterface $entity, array $data, array $options = [])
* @method \CakeAddresses\Model\Entity\Address get()
* @method \CakeAddresses\Model\Entity\Address findOrCreate()
* @method \CakeAddresses\Model\Entity\Address patchEntity()
* @method array<Address> patchEntities(iterable $entities, array $data, array $options = [])
* @method Address|false save(EntityInterface $entity, array $options = [])
* @method Address saveOrFail(EntityInterface $entity, array $options = [])
* @method \CakeAddresses\Model\Entity\Address saveOrFail()
* @method iterable<Address>|ResultSetInterface<Address>|false saveMany(iterable $entities, array $options = [])
* @method iterable<Address>|ResultSetInterface<Address> saveManyOrFail(iterable $entities, array $options = [])
* @method iterable<Address>|ResultSetInterface<Address>|false deleteMany(iterable $entities, array $options = [])
* @method iterable<Address>|ResultSetInterface<Address> deleteManyOrFail(iterable $entities, array $options = [])
*/
class AddressesTable extends Table
{
/**
class AddressesTable extends Table {
/**
* Initialize method
*
* @param array<string, mixed> $config The configuration for the Table.
* @return void
*/
public function initialize(array $config): void
{
parent::initialize($config);
public function initialize(array $config): void {
parent::initialize($config);
$this->setTable('addresses');
$this->setDisplayField('address_line1');
$this->setPrimaryKey('id');
$this->setTable('addresses');
$this->setDisplayField('address_line1');
$this->setPrimaryKey('id');
$this->belongsTo('Cities', [
'foreignKey' => 'city_id',
'className' => 'CakeAddresses.Cities',
'propertyName' => 'city_entity',
]);
$this->belongsTo('States', [
'foreignKey' => 'state_id',
'className' => 'CakeAddresses.States',
'propertyName' => 'state_entity',
]);
$this->belongsTo('Countries', [
'foreignKey' => 'country_id',
'className' => 'CakeAddresses.Countries',
'propertyName' => 'country_entity',
]);
}
$this->belongsTo('Cities', [
'foreignKey' => 'city_id',
'className' => 'CakeAddresses.Cities',
'propertyName' => 'city_entity',
]);
$this->belongsTo('States', [
'foreignKey' => 'state_id',
'className' => 'CakeAddresses.States',
'propertyName' => 'state_entity',
]);
$this->belongsTo('Countries', [
'foreignKey' => 'country_id',
'className' => 'CakeAddresses.Countries',
'propertyName' => 'country_entity',
]);
}
/**
/**
* Default validation rules.
*
* @param Validator $validator Validator instance.
* @return Validator
* @param \Cake\Validation\Validator $validator Validator instance.
* @return \Cake\Validation\Validator
*/
public function validationDefault(Validator $validator): Validator
{
$validator
->scalar('address_name')
->maxLength('address_name', 255)
->allowEmptyString('address_name');
public function validationDefault(Validator $validator): Validator {
$validator
->scalar('address_name')
->maxLength('address_name', 255)
->allowEmptyString('address_name');
$validator
->scalar('contact_name')
->maxLength('contact_name', 255)
->allowEmptyString('contact_name');
$validator
->scalar('contact_name')
->maxLength('contact_name', 255)
->allowEmptyString('contact_name');
$validator
->scalar('address_line1')
->maxLength('address_line1', 255)
->requirePresence('address_line1', 'create')
->notEmptyString('address_line1');
$validator
->scalar('address_line1')
->maxLength('address_line1', 255)
->requirePresence('address_line1', 'create')
->notEmptyString('address_line1');
$validator
->scalar('address_line2')
->maxLength('address_line2', 255)
->allowEmptyString('address_line2');
$validator
->scalar('address_line2')
->maxLength('address_line2', 255)
->allowEmptyString('address_line2');
$validator
->scalar('city')
->maxLength('city', 255)
->requirePresence('city', 'create')
->notEmptyString('city');
$validator
->scalar('city')
->maxLength('city', 255)
->requirePresence('city', 'create')
->notEmptyString('city');
$validator
->integer('city_id')
->allowEmptyString('city_id');
$validator
->integer('city_id')
->allowEmptyString('city_id');
$validator
->scalar('state')
->maxLength('state', 255)
->requirePresence('state', 'create')
->notEmptyString('state');
$validator
->scalar('state')
->maxLength('state', 255)
->requirePresence('state', 'create')
->notEmptyString('state');
$validator
->integer('state_id')
->allowEmptyString('state_id');
$validator
->integer('state_id')
->allowEmptyString('state_id');
$validator
->scalar('postal_code')
->maxLength('postal_code', 25)
->requirePresence('postal_code', 'create')
->notEmptyString('postal_code');
$validator
->scalar('postal_code')
->maxLength('postal_code', 25)
->requirePresence('postal_code', 'create')
->notEmptyString('postal_code');
$validator
->scalar('country')
->maxLength('country', 255)
->requirePresence('country', 'create')
->notEmptyString('country');
$validator
->scalar('country')
->maxLength('country', 255)
->requirePresence('country', 'create')
->notEmptyString('country');
$validator
->integer('country_id')
->allowEmptyString('country_id');
$validator
->integer('country_id')
->allowEmptyString('country_id');
$validator
->scalar('phone_number')
->maxLength('phone_number', 25)
->allowEmptyString('phone_number');
$validator
->scalar('phone_number')
->maxLength('phone_number', 25)
->allowEmptyString('phone_number');
$validator
->email('email')
->allowEmptyString('email');
$validator
->email('email')
->allowEmptyString('email');
$validator
->scalar('notes')
->allowEmptyString('notes');
$validator
->scalar('notes')
->allowEmptyString('notes');
$validator
->scalar('foreign_key')
->maxLength('foreign_key', 45)
->allowEmptyString('foreign_key');
$validator
->scalar('foreign_key')
->maxLength('foreign_key', 45)
->allowEmptyString('foreign_key');
$validator
->scalar('model')
->maxLength('model', 255)
->allowEmptyString('model');
$validator
->scalar('model')
->maxLength('model', 255)
->allowEmptyString('model');
return $validator;
}
return $validator;
}
/**
/**
* Returns a rules checker object that will be used for validating
* application integrity.
*
* @param RulesChecker $rules The rules object to be modified.
* @return RulesChecker
* @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
* @return \Cake\ORM\RulesChecker
*/
public function buildRules(RulesChecker $rules): RulesChecker
{
$rules->add($rules->existsIn('city_id', 'Cities'), ['errorField' => 'city_id']);
$rules->add($rules->existsIn('state_id', 'States'), ['errorField' => 'state_id']);
$rules->add($rules->existsIn('country_id', 'Countries'), ['errorField' => 'country_id']);
public function buildRules(RulesChecker $rules): RulesChecker {
$rules->add($rules->existsIn('city_id', 'Cities'), ['errorField' => 'city_id']);
$rules->add($rules->existsIn('state_id', 'States'), ['errorField' => 'state_id']);
$rules->add($rules->existsIn('country_id', 'Countries'), ['errorField' => 'country_id']);
return $rules;
}
return $rules;
}
/**
* @param EventInterface $event
* @param ArrayObject $data
* @param ArrayObject $options
/**
* @param \Cake\Event\EventInterface $event
* @param \ArrayObject $data
* @param \ArrayObject $options
*
* @return void
*/
public function beforeMarshal(EventInterface $event, ArrayObject $data, ArrayObject $options): void
{
if ($data['state_id'] && !isset($data['state'])) {
$state = $this->States->find()->where(['id' => $data['state_id']])->first();
$data['state'] = $state->name ?? null;
}
if ($data['country_id'] && !isset($data['country'])) {
$country = $this->Countries->find()->where(['id' => $data['country_id']])->first();
$data['country'] = $country->name ?? null;
}
}
public function beforeMarshal(EventInterface $event, ArrayObject $data, ArrayObject $options): void {
if ($data['state_id'] && !isset($data['state'])) {
$state = $this->States->find()->where(['id' => $data['state_id']])->first();
$data['state'] = $state->name ?? null;
}
if ($data['country_id'] && !isset($data['country'])) {
$country = $this->Countries->find()->where(['id' => $data['country_id']])->first();
$data['country'] = $country->name ?? null;
}
}
}