├── .editorconfig ├── .github ├── FUNDING.yml └── workflows │ ├── PhpUnit-MacOs.yaml │ ├── PhpUnit-Win.yaml │ ├── PhpUnit.yaml │ └── Psalm.yaml ├── .gitignore ├── Attributes ├── AccessControl.php ├── Action.php ├── JsonItem.php ├── JsonParam.php ├── Param.php └── Path.php ├── Autoloader.php ├── BaseMapper.php ├── BaseModel.php ├── Binary.php ├── CliArguments.php ├── CliController.php ├── Collection ├── Collection.php ├── CollectionList.php └── Set.php ├── Config ├── Config.php └── FeatureFlag.php ├── Controllers ├── CacheController.php ├── CreateController.php ├── JobController.php ├── MaintenanceController.php ├── MigrationController.php ├── ServeController.php ├── TemplateController.php └── WriteTemplateController.php ├── Csv ├── Csv.php ├── CsvReader.php └── CsvWriter.php ├── Database ├── Column │ ├── BigInt.php │ ├── Blob.php │ ├── Char.php │ ├── Column.php │ ├── Decimal.php │ ├── Integer.php │ ├── LongBlob.php │ ├── LongText.php │ ├── MediumBlob.php │ ├── MediumInt.php │ ├── MediumText.php │ ├── Postgres │ │ ├── BigInt.php │ │ ├── Boolean.php │ │ ├── Bytea.php │ │ ├── Integer.php │ │ ├── SmallInt.php │ │ └── Text.php │ ├── SmallInt.php │ ├── Text.php │ ├── TinyBlob.php │ ├── TinyInt.php │ ├── TinyText.php │ └── VarChar.php ├── Database.php ├── DatabaseDetails.php ├── DatabaseFactory.php ├── FieldDetails.php ├── Migration.php ├── MySQLQuery.php ├── PostgresQuery.php ├── Query.php ├── SQLiteQuery.php ├── Table │ ├── Ddl.php │ ├── MySQLTable.php │ ├── PostgresTable.php │ ├── Table.php │ └── TableFactory.php └── TableDetails.php ├── Date.php ├── Deferred.php ├── DeferredCall.php ├── DependencyInjector.php ├── Email ├── Attachment.php ├── Email.php └── Recipient.php ├── Enums ├── CollectionSort.php ├── DatabaseType.php ├── DocType.php ├── LogLevelCode.php ├── ParamType.php ├── RequestMethod.php ├── ResponseCode.php └── ServiceContainer.php ├── Exception ├── BadRequestException.php ├── ConfigException.php ├── CurlException.php ├── DatabaseException.php ├── Error404Exception.php ├── InvalidArgumentException.php ├── InvalidDateException.php ├── InvalidOptionException.php ├── NotFoundException.php ├── RouteException.php ├── ServerFailureException.php ├── SessionNotStartedException.php └── ThrottleException.php ├── FeastTests ├── Attributes │ ├── ActionTest.php │ ├── ParamTest.php │ └── PathTest.php ├── AutoloaderTest.php ├── BaseMapperTest.php ├── BaseModelTest.php ├── BinaryTest.php ├── Collection │ ├── CollectionListTest.php │ └── SetTest.php ├── ConfigTest │ ├── ConfigTest.php │ └── FeatureFlagTest.php ├── ControllerTest.php ├── Controllers │ ├── CacheControllerTest.php │ ├── CreateControllerTest.php │ ├── EmptyCliController.php │ ├── EmptyController.php │ ├── JobControllerTest.php │ ├── MaintenanceControllerTest.php │ ├── MigrationControllerTest.php │ ├── ServeControllerTest.php │ ├── TemplateControllerTest.php │ └── TestingController.php ├── Csv │ ├── CsvReaderTest.php │ └── CsvWriterTest.php ├── Database │ ├── Column │ │ ├── BigIntTest.php │ │ ├── BlobTest.php │ │ ├── CharTest.php │ │ ├── DecimalTest.php │ │ ├── IntegerTest.php │ │ ├── LongBlobTest.php │ │ ├── LongTextTest.php │ │ ├── MediumBlobTest.php │ │ ├── MediumIntTest.php │ │ ├── MediumTextTest.php │ │ ├── SmallIntTest.php │ │ ├── TextTest.php │ │ ├── TinyBlobTest.php │ │ ├── TinyIntTest.php │ │ ├── TinyTextTest.php │ │ └── VarCharTest.php │ ├── DatabaseDetailsTest.php │ ├── DatabaseFactoryTest.php │ ├── DatabaseTest.php │ ├── MigrationTest.php │ ├── MySQLQueryTest.php │ ├── PostgresQueryTest.php │ ├── SQLiteQueryTest.php │ └── Table │ │ ├── MySQLTableTest.php │ │ ├── PostgresTableTest.php │ │ └── TableFactoryTest.php ├── DateTest.php ├── DeferredTest.php ├── Email │ ├── AttachmentTest.php │ ├── EmailTest.php │ ├── RecipientTest.php │ └── test.txt ├── ErrorLoggerTest.php ├── Exception │ ├── Error404ExceptionTest.php │ └── ServerFailureExceptionTest.php ├── ExpectedOutputs │ ├── testCreateModel.txt │ ├── testCreateModelAlreadyExists.txt │ ├── testCreateModelAlreadyExistsNoPrimary.txt │ ├── testCreateModelCompoundPrimary.txt │ └── testCreateModelNoPrimary.txt ├── FlashMessageTest.php ├── Form │ └── Field │ │ ├── CheckboxTest.php │ │ ├── RadioTest.php │ │ ├── SelectTest.php │ │ ├── TextTest.php │ │ └── TextareaTest.php ├── FormTest.php ├── HelpTest.php ├── HttpRequest │ ├── CookieTest.php │ ├── CurlTest.php │ └── SimpleTest.php ├── IdentityTest.php ├── Jobs │ ├── CronJobTest.php │ └── QueueableJobTest.php ├── JsonTest.php ├── Logger │ └── LoggerTest.php ├── MainTest.php ├── Mapper │ ├── JobMapper.php │ └── MigrationMapper.php ├── Migrations │ ├── migration1_migrations.php │ ├── migration2_test.php │ └── migration3_blowup.php ├── Mocks │ ├── BadJsonItem.php │ ├── ConfigClassFileFunctions.mock │ ├── ControllersFileFunctions.mock │ ├── Curl.mock │ ├── DatabaseFunctions.mock │ ├── DeferredMock.php │ ├── EmailClassFileFunctions.mock │ ├── FeastMocks.mock │ ├── FormClassFileFunctions.mock │ ├── FormValidatorsFileFunctions.mock │ ├── InjectedMock.php │ ├── JobFileFunctions.mock │ ├── LoggerClassFileFunctions.mock │ ├── LoggerMock.php │ ├── MigrationMock.php │ ├── MigrationMockNoConnection.php │ ├── MigrationMockNoName.php │ ├── MockBaseMapper.php │ ├── MockBaseModel.php │ ├── MockBaseModelNoMapper.php │ ├── MockCronJob.php │ ├── MockJob.php │ ├── MockUser.php │ ├── PDOMock.php │ ├── PDOStatementMigrationMock.php │ ├── PDOStatementMock.php │ ├── PDOStatementSchemaMock.php │ ├── PDOStatementSchemaPostgresMock.php │ ├── ProfilerFunctions.mock │ ├── README.md │ ├── RouterClassFileFunctions.mock │ ├── SampleResponses │ │ ├── GetHtml.txt │ │ ├── GetJson.txt │ │ ├── GetXml.txt │ │ └── SimpleGetHtml.txt │ ├── SecondItem.php │ ├── SessionFunctions.mock │ └── TestJsonItem.php ├── Model │ ├── Job.php │ └── Migration.php ├── Modules │ ├── CLI │ │ └── Controllers │ │ │ ├── FeastTestController.php │ │ │ ├── IndexController.php │ │ │ └── SmallController.php │ └── Test │ │ └── Controllers │ │ ├── FeastInitFailedController.php │ │ └── FeastTestController.php ├── NameHelperTest.php ├── OsSafeTestCase.php ├── PluginTest.php ├── Plugins │ ├── TestPlugin.php │ └── ThrottleExceptionPlugin.php ├── ProfilerTest.php ├── RequestTest.php ├── ResponseTest.php ├── Router │ └── RouterTest.php ├── ServiceContainer │ └── ServiceContainerTest.php ├── ServiceTest.php ├── SessionTest.php ├── TerminalTest.php ├── ViewTest.php ├── Views │ ├── Error │ │ └── server-failure.phtml │ ├── Test │ │ └── Test.phtml │ └── layout.phtml ├── bootstrap.php ├── config.ini ├── config.local.ini ├── configs │ ├── config.local.php │ └── config.php ├── githubphpunit.xml └── scheduled_jobs.php ├── FlashMessage.php ├── Form ├── Field.php ├── Field │ ├── Checkbox.php │ ├── CheckboxAndRadio.php │ ├── Radio.php │ ├── Select.php │ ├── SelectValue.php │ ├── Text.php │ ├── Textarea.php │ └── Value.php ├── Filter │ ├── Filter.php │ ├── Md5.php │ ├── Sha1.php │ └── Trim.php ├── Form.php ├── Label.php └── Validator │ ├── AlphaNumeric.php │ ├── AlphaNumericSpaces.php │ ├── Alphabetical.php │ ├── Decimal.php │ ├── Email.php │ ├── File.php │ ├── Image.php │ ├── Numeric.php │ ├── Url.php │ └── Validator.php ├── Help.php ├── HttpController.php ├── HttpRequest ├── Cookie.php ├── Curl.php ├── HttpRequest.php ├── Response.php └── Simple.php ├── Install ├── .appenv ├── Controllers │ ├── ErrorController.php │ └── IndexController.php ├── Mapper │ ├── JobMapper.php.txt │ └── MigrationMapper.php.txt ├── Migrations │ ├── migration1_migrations.php │ └── migration2_jobs.php ├── Model │ ├── Job.php.txt │ └── Migration.php.txt ├── Views │ ├── Error │ │ ├── fourohfour.phtml │ │ ├── maintenance-screen.phtml │ │ ├── rate-limit.phtml │ │ └── server-failure.phtml │ ├── Index │ │ └── index.phtml │ └── layout.phtml ├── bin │ ├── router.php │ └── templates │ │ ├── Action.php.txt │ │ ├── CliAction.php.txt │ │ ├── Controller.php.txt │ │ ├── CronJob.php.txt │ │ ├── FeatureFlag.php.txt │ │ ├── Filter.php.txt │ │ ├── Form.php.txt │ │ ├── Mapper.php.txt │ │ ├── Migration.php.txt │ │ ├── Model.php.txt │ │ ├── ModelGenerated.php.txt │ │ ├── NoKeyMapper.php.txt │ │ ├── Plugin.php.txt │ │ ├── QueueableJob.php.txt │ │ ├── Service.php.txt │ │ ├── Validator.php.txt │ │ └── layout.phtml ├── bootstrap.php ├── composer-install.php ├── configs │ ├── config.local.php │ └── config.php ├── container.php ├── famine ├── gitignore.template ├── install.php ├── public │ ├── .htaccess │ ├── favicon.ico │ ├── icons │ │ ├── android-chrome-192x192.png │ │ ├── android-chrome-512x512.png │ │ ├── apple-touch-icon.png │ │ ├── browserconfig.xml │ │ ├── favicon-16x16.png │ │ ├── favicon-32x32.png │ │ ├── mstile-150x150.png │ │ ├── safari-pinned-tab.svg │ │ └── site.webmanifest │ ├── index.php │ └── maintenance-screen.html └── scheduled_jobs.php ├── Interfaces ├── ConfigInterface.php ├── ControllerInterface.php ├── DatabaseDetailsInterface.php ├── DatabaseFactoryInterface.php ├── DatabaseInterface.php ├── ErrorLoggerInterface.php ├── FeatureFlagInterface.php ├── HttpRequestInterface.php ├── JobInterface.php ├── LoggerInterface.php ├── MainInterface.php ├── ProfilerInterface.php ├── RequestInterface.php ├── ResponseInterface.php └── RouterInterface.php ├── Jobs ├── CronJob.php └── QueueableJob.php ├── Json.php ├── LICENSE ├── Logger ├── ErrorLogger.php └── Logger.php ├── Main.php ├── NameHelper.php ├── Partial.php ├── Plugin.php ├── Profiler └── Profiler.php ├── PsalmLoader.php ├── Psr ├── Container │ ├── ContainerExceptionInterface.php │ ├── ContainerInterface.php │ └── NotFoundExceptionInterface.php └── Log │ ├── InvalidArgumentException.php │ ├── LogLevel.php │ └── LoggerInterface.php ├── README.md ├── Request.php ├── Response.php ├── Router ├── RouteData.php └── Router.php ├── Service.php ├── ServiceContainer ├── ContainerException.php ├── NotFoundException.php ├── ServiceContainer.php └── ServiceContainerItemInterface.php ├── Session ├── Identity.php └── Session.php ├── Terminal.php ├── Traits ├── Collection.php ├── DebugQuery.php └── DependencyInjected.php ├── View.php ├── bootstrap.php ├── composer.json ├── composer.lock ├── configs ├── config.local.php └── config.php ├── docs ├── CONTRIBUTING.md ├── _config.yml ├── access-control.md ├── cli.md ├── collections.md ├── config.md ├── contributors.md ├── controller.md ├── cron-jobs.md ├── csv.md ├── date.md ├── deferred.md ├── first-controller.md ├── forms.md ├── index.md ├── install.md ├── json-standalone-74.md ├── json-standalone.md ├── json.md ├── logger.md ├── logo.png ├── models.md ├── plugin.md ├── queues.md ├── release-schedule.md ├── routing.md ├── service-container.md ├── services.md ├── sessions.md ├── throttle.md └── view.md ├── logos ├── feast-simple-transparent-small.png ├── feast-simple-transparent.png ├── feast-simple.png ├── feast-transparent-small.png ├── feast-transparent.png ├── feast.png ├── mini-transparent.png └── mini.png ├── phpunit.xml └── psalm.xml /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: jpresutti 4 | -------------------------------------------------------------------------------- /.github/workflows/PhpUnit-MacOs.yaml: -------------------------------------------------------------------------------- 1 | name: PHPUnit MacOS 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build-test: 7 | runs-on: macos-latest 8 | 9 | steps: 10 | - uses: actions/checkout@v2 11 | - uses: shivammathur/setup-php@v2 12 | with: 13 | php-version: '8.2' 14 | extensions: bcmath 15 | coverage: xdebug 16 | tools: phpunit 17 | - name: Run PHPUnit 18 | run: phpunit -c FeastTests/githubphpunit.xml --coverage-clover coverage.xml 19 | -------------------------------------------------------------------------------- /.github/workflows/PhpUnit-Win.yaml: -------------------------------------------------------------------------------- 1 | name: PHPUnit Windows 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build-test: 7 | runs-on: windows-latest 8 | 9 | steps: 10 | - uses: actions/checkout@v2 11 | - uses: shivammathur/setup-php@v2 12 | with: 13 | php-version: '8.2' 14 | extensions: bcmath 15 | coverage: xdebug 16 | tools: phpunit 17 | - name: Run PHPUnit 18 | run: phpunit -c FeastTests/githubphpunit.xml --coverage-clover coverage.xml 19 | -------------------------------------------------------------------------------- /.github/workflows/PhpUnit.yaml: -------------------------------------------------------------------------------- 1 | name: PHPUnit Linux 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build-test: 7 | runs-on: ubuntu-latest 8 | 9 | steps: 10 | - uses: actions/checkout@v2 11 | - uses: shivammathur/setup-php@v2 12 | with: 13 | php-version: '8.2' 14 | extensions: bcmath 15 | coverage: xdebug 16 | tools: phpunit 17 | - name: Run PHPUnit 18 | run: phpunit -c FeastTests/githubphpunit.xml --coverage-clover coverage.xml 19 | - uses: codecov/codecov-action@v1 20 | with: 21 | token: ${{ secrets.CODECOV_TOKEN }} 22 | file: coverage.xml 23 | flags: tests 24 | name: codecov-umbrella 25 | fail_ci_if_error: false -------------------------------------------------------------------------------- /.github/workflows/Psalm.yaml: -------------------------------------------------------------------------------- 1 | name: Psalm Static analysis 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | psalm: 7 | name: Psalm 8 | runs-on: ubuntu-latest 9 | steps: 10 | - name: Setup PHP 11 | uses: shivammathur/setup-php@v2 12 | with: 13 | php-version: '8.2' 14 | - name: Checkout project 15 | uses: actions/checkout@v2 16 | 17 | - name: Get composer cache directory 18 | id: composer-cache 19 | run: echo "::set-output name=dir::$(composer config cache-files-dir)" 20 | 21 | - name: Cache dependencies 22 | uses: actions/cache@v2 23 | with: 24 | path: ${{ steps.composer-cache.outputs.dir }} 25 | key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} 26 | restore-keys: ${{ runner.os }}-composer- 27 | 28 | - name: Install dependencies 29 | run: composer install --prefer-dist 30 | 31 | - name: Run Psalm 32 | run: ./vendor/bin/psalm.phar --show-info=true --no-diff --report=results.sarif 33 | 34 | - name: Upload Security Analysis results to GitHub 35 | continue-on-error: true 36 | uses: github/codeql-action/upload-sarif@v1 37 | with: 38 | sarif_file: results.sarif -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | vendor/* 2 | FeastTests/Coverage 3 | .fleet 4 | .idea -------------------------------------------------------------------------------- /Attributes/AccessControl.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Attributes; 22 | 23 | use Attribute; 24 | 25 | #[Attribute(Attribute::TARGET_METHOD)] 26 | readonly class AccessControl 27 | { 28 | /** 29 | * AccessControl constructor. 30 | * 31 | * @param list|null $disabledEnvironments 32 | * @param list|null $onlyEnvironments 33 | */ 34 | public function __construct( 35 | public ?array $disabledEnvironments = null, 36 | public ?array $onlyEnvironments = null, 37 | ) { 38 | } 39 | 40 | public function isEnabled(string $environment): bool 41 | { 42 | if ($this->onlyEnvironments !== null && !in_array($environment, $this->onlyEnvironments)) { 43 | return false; 44 | } 45 | 46 | if ($this->disabledEnvironments !== null && in_array($environment, $this->disabledEnvironments)) { 47 | return false; 48 | } 49 | 50 | return true; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /Attributes/Action.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Attributes; 22 | 23 | use Attribute; 24 | 25 | #[Attribute(Attribute::TARGET_METHOD)] 26 | readonly class Action 27 | { 28 | public function __construct(public string $usage = '', public string $description = '') 29 | { 30 | } 31 | 32 | /** 33 | * Get pretty format usage text 34 | * 35 | * @param string $usage 36 | * @param string $name 37 | * @return string 38 | */ 39 | public function getHelpText(string $usage, string $name): string 40 | { 41 | return trim(implode(' ', ['Usage:', $usage, $name, $this->usage])); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Attributes/JsonParam.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Attributes; 22 | 23 | use Attribute; 24 | 25 | #[Attribute(Attribute::TARGET_PARAMETER)] 26 | readonly class JsonParam 27 | { 28 | public function __construct(public string $key = '') 29 | { 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /CliArguments.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast; 22 | 23 | use Feast\ServiceContainer\ServiceContainerItemInterface; 24 | 25 | class CliArguments implements ServiceContainerItemInterface 26 | { 27 | 28 | public function __construct(protected array $arguments = []) 29 | { 30 | } 31 | 32 | /** 33 | * Get CLI arguments. 34 | * @return array 35 | */ 36 | public function getArguments(): array 37 | { 38 | return $this->arguments; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Collection/Collection.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Collection; 22 | 23 | interface Collection 24 | { 25 | public function toArray(): array; 26 | } 27 | -------------------------------------------------------------------------------- /Config/FeatureFlag.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Config; 22 | 23 | use Feast\Interfaces\FeatureFlagInterface; 24 | 25 | /** 26 | * 27 | * Class to manage feature flags. 28 | */ 29 | class FeatureFlag implements FeatureFlagInterface 30 | { 31 | public function __construct(protected bool $isEnabled) 32 | { 33 | } 34 | 35 | /** 36 | * Returns true if the feature should be enabled, false otherwise 37 | * @return bool 38 | */ 39 | public function isEnabled(): bool 40 | { 41 | return $this->isEnabled; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /Controllers/WriteTemplateController.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Controllers; 22 | 23 | use Feast\CliController; 24 | use Feast\Main; 25 | 26 | abstract class WriteTemplateController extends CliController { 27 | 28 | protected function getTemplateFilePath(string $type): string 29 | { 30 | $basePath = DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . $type . '.php.txt'; 31 | if ( file_exists(APPLICATION_ROOT . $basePath) ) { 32 | return APPLICATION_ROOT . $basePath; 33 | } 34 | return Main::FRAMEWORK_ROOT . DIRECTORY_SEPARATOR . 'Install' . $basePath; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Database/Column/BigInt.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Database\Column; 22 | 23 | use Feast\Exception\DatabaseException; 24 | 25 | class BigInt extends Integer 26 | { 27 | public const TYPE = 'bigint'; 28 | 29 | /** 30 | * Create BigInt column 31 | * 32 | * @param string $name 33 | * @param positive-int $length 34 | * @param bool $unsigned 35 | * @param bool $nullable 36 | * @param int|null $default 37 | * @param string|null $comment 38 | * @throws DatabaseException 39 | */ 40 | public function __construct( 41 | string $name, 42 | int $length = 20, 43 | bool $unsigned = false, 44 | bool $nullable = false, 45 | ?int $default = null, 46 | ?string $comment = null 47 | ) { 48 | parent::__construct($name, $length, $unsigned, $nullable, $default, $comment); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Database/Column/Blob.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Database\Column; 22 | 23 | use Feast\Exception\DatabaseException; 24 | 25 | class Blob extends Char 26 | { 27 | public const TYPE = 'BLOB'; 28 | 29 | /** 30 | * Create Blob column. 31 | * 32 | * @param string $name 33 | * @param null|positive-int $length 34 | * @param bool $nullable 35 | * @param string|null $comment 36 | * @throws DatabaseException 37 | */ 38 | public function __construct(string $name, ?int $length = null, bool $nullable = false, ?string $comment = null) 39 | { 40 | parent::__construct($name, $length, nullable: $nullable, comment: $comment); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /Database/Column/Char.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Database\Column; 22 | 23 | use Feast\Exception\DatabaseException; 24 | 25 | class Char extends Column 26 | { 27 | public const TYPE = 'CHAR'; 28 | 29 | /** 30 | * Create Char column. 31 | * 32 | * @param string $name 33 | * @param positive-int|null $length 34 | * @param string|null $default 35 | * @param bool $nullable 36 | * @param string|null $comment 37 | * @throws DatabaseException 38 | */ 39 | public function __construct(string $name, ?int $length = 255, ?string $default = null, bool $nullable = false, ?string $comment = null) 40 | { 41 | parent::__construct($name, $length, (string)static::TYPE, nullable: $nullable, default: $default, comment: $comment); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /Database/Column/LongBlob.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Database\Column; 22 | 23 | use Feast\Exception\DatabaseException; 24 | 25 | class LongBlob extends Char 26 | { 27 | public const TYPE = 'LongBlob'; 28 | 29 | /** 30 | * Create LongBlob column. 31 | * 32 | * @param string $name 33 | * @param null|positive-int $length 34 | * @param bool $nullable 35 | * @param string|null $comment 36 | * @throws DatabaseException 37 | */ 38 | public function __construct(string $name, ?int $length = null, bool $nullable = false, ?string $comment = null) 39 | { 40 | parent::__construct($name, $length, nullable: $nullable, comment: $comment); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /Database/Column/LongText.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Database\Column; 22 | 23 | use Feast\Exception\DatabaseException; 24 | 25 | class LongText extends Char 26 | { 27 | public const TYPE = 'LongText'; 28 | 29 | /** 30 | * Create LongText column. 31 | * 32 | * @param string $name 33 | * @param null|positive-int $length 34 | * @param bool $nullable 35 | * @param string|null $comment 36 | * @throws DatabaseException 37 | */ 38 | public function __construct(string $name, ?int $length = null, bool $nullable = false, ?string $comment = null) 39 | { 40 | parent::__construct($name, $length, nullable: $nullable, comment: $comment); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /Database/Column/MediumBlob.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Database\Column; 22 | 23 | use Feast\Exception\DatabaseException; 24 | 25 | class MediumBlob extends Char 26 | { 27 | public const TYPE = 'MediumBlob'; 28 | 29 | /** 30 | * Create MediumBlob. 31 | * 32 | * @param string $name 33 | * @param null|positive-int $length 34 | * @param bool $nullable 35 | * @param string|null $comment 36 | * @throws DatabaseException 37 | */ 38 | public function __construct(string $name, ?int $length = null, bool $nullable = false, ?string $comment = null) 39 | { 40 | parent::__construct($name, $length, nullable: $nullable, comment: $comment); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /Database/Column/MediumInt.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Database\Column; 22 | 23 | use Feast\Exception\DatabaseException; 24 | 25 | class MediumInt extends Integer 26 | { 27 | public const TYPE = 'mediumint'; 28 | 29 | /** 30 | * Create MediumInt column. 31 | * 32 | * @param string $name 33 | * @param positive-int $length 34 | * @param bool $unsigned 35 | * @param bool $nullable 36 | * @param int|null $default 37 | * @param string|null $comment 38 | * @throws DatabaseException 39 | */ 40 | public function __construct(string $name, int $length = 8, bool $unsigned = false, bool $nullable = false, ?int $default = null, ?string $comment = null) 41 | { 42 | parent::__construct($name, $length, $unsigned, $nullable, $default, $comment); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Database/Column/MediumText.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Database\Column; 22 | 23 | use Feast\Exception\DatabaseException; 24 | 25 | class MediumText extends Char 26 | { 27 | public const TYPE = 'MEDIUMTEXT'; 28 | 29 | /** 30 | * Create MediumText column. 31 | * 32 | * @param string $name 33 | * @param null|positive-int $length 34 | * @param bool $nullable 35 | * @param string|null $comment 36 | * @throws DatabaseException 37 | */ 38 | public function __construct(string $name, ?int $length = null, bool $nullable = false, ?string $comment = null) 39 | { 40 | parent::__construct($name, $length, nullable: $nullable, comment: $comment); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /Database/Column/Postgres/BigInt.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Database\Column\Postgres; 22 | 23 | use Feast\Exception\DatabaseException; 24 | 25 | class BigInt extends Integer 26 | { 27 | public const TYPE = 'bigint'; 28 | 29 | /** 30 | * Create Integer column. 31 | * 32 | * @param string $name 33 | * @param bool $nullable 34 | * @param int|null $default 35 | * @param string|null $comment 36 | * @throws DatabaseException 37 | */ 38 | public function __construct( 39 | string $name, 40 | bool $nullable = false, 41 | ?int $default = null, 42 | ?string $comment = null 43 | ) { 44 | parent::__construct($name, $nullable, $default, $comment); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /Database/Column/Postgres/Boolean.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Database\Column\Postgres; 22 | 23 | use Feast\Database\Column\Column; 24 | use Feast\Exception\DatabaseException; 25 | 26 | class Boolean extends Column 27 | { 28 | public const TYPE = 'bool'; 29 | 30 | /** 31 | * Create Boolean column. 32 | * 33 | * @param string $name 34 | * @param bool $nullable 35 | * @param bool|null $default 36 | * @param string|null $comment 37 | * @throws DatabaseException 38 | */ 39 | public function __construct(string $name, bool $nullable = false, ?bool $default = null, ?string $comment = null) 40 | { 41 | parent::__construct($name, null, self::TYPE,nullable: $nullable, default: $default, comment: $comment); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Database/Column/Postgres/Bytea.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Database\Column\Postgres; 22 | 23 | use Feast\Database\Column\Column; 24 | use Feast\Exception\DatabaseException; 25 | 26 | class Bytea extends Column 27 | { 28 | public const TYPE = 'bytea'; 29 | 30 | /** 31 | * Create Blob column. 32 | * 33 | * @param string $name 34 | * @param bool $nullable 35 | * @param string|null $comment 36 | * @throws DatabaseException 37 | */ 38 | public function __construct(string $name, bool $nullable = false, ?string $comment = null) 39 | { 40 | parent::__construct($name, null, self::TYPE, nullable: $nullable, comment: $comment); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /Database/Column/Postgres/Integer.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Database\Column\Postgres; 22 | 23 | use Feast\Database\Column\Column; 24 | use Feast\Exception\DatabaseException; 25 | 26 | class Integer extends Column 27 | { 28 | public const TYPE = 'integer'; 29 | 30 | /** 31 | * Create Integer column. 32 | * 33 | * @param string $name 34 | * @param bool $nullable 35 | * @param int|null $default 36 | * @param string|null $comment 37 | * @throws DatabaseException 38 | */ 39 | public function __construct( 40 | string $name, 41 | bool $nullable = false, 42 | ?int $default = null, 43 | ?string $comment = null 44 | ) { 45 | parent::__construct($name, null, (string)static::TYPE, nullable: $nullable, default: $default, comment: $comment); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /Database/Column/Postgres/SmallInt.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Database\Column\Postgres; 22 | 23 | use Feast\Exception\DatabaseException; 24 | 25 | class SmallInt extends Integer 26 | { 27 | public const TYPE = 'smallint'; 28 | 29 | /** 30 | * Create Integer column. 31 | * 32 | * @param string $name 33 | * @param bool $nullable 34 | * @param int|null $default 35 | * @param string|null $comment 36 | * @throws DatabaseException 37 | */ 38 | public function __construct( 39 | string $name, 40 | bool $nullable = false, 41 | ?int $default = null, 42 | ?string $comment = null 43 | ) { 44 | parent::__construct($name, $nullable, $default, $comment); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /Database/Column/Postgres/Text.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Database\Column\Postgres; 22 | 23 | use Feast\Database\Column\Column; 24 | use Feast\Exception\DatabaseException; 25 | 26 | class Text extends Column 27 | { 28 | public const TYPE = 'TEXT'; 29 | 30 | /** 31 | * Create Text column. 32 | * 33 | * @param string $name 34 | * @param bool $nullable 35 | * @param string|null $default 36 | * @param string|null $comment 37 | * @throws DatabaseException 38 | */ 39 | public function __construct(string $name, bool $nullable = false, ?string $default = null, ?string $comment = null) 40 | { 41 | parent::__construct($name, null, (string)static::TYPE, nullable: $nullable, default: $default, comment: $comment); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /Database/Column/SmallInt.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Database\Column; 22 | 23 | use Feast\Exception\DatabaseException; 24 | 25 | class SmallInt extends Integer 26 | { 27 | public const TYPE = 'smallint'; 28 | 29 | /** 30 | * Create SmallInt column. 31 | * 32 | * @param string $name 33 | * @param positive-int $length 34 | * @param bool $unsigned 35 | * @param bool $nullable 36 | * @param int|null $default 37 | * @param string|null $comment 38 | * @throws DatabaseException 39 | */ 40 | public function __construct(string $name, int $length = 6, bool $unsigned = false, bool $nullable = false, ?int $default = null, ?string $comment = null) 41 | { 42 | parent::__construct($name, $length, $unsigned, $nullable, $default, $comment); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Database/Column/Text.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Database\Column; 22 | 23 | use Feast\Exception\DatabaseException; 24 | 25 | class Text extends Char 26 | { 27 | public const TYPE = 'TEXT'; 28 | 29 | /** 30 | * Create Text column. 31 | * 32 | * @param string $name 33 | * @param null|positive-int $length 34 | * @param bool $nullable 35 | * @param string|null $comment 36 | * @throws DatabaseException 37 | */ 38 | public function __construct(string $name, ?int $length = null, bool $nullable = false, ?string $comment = null) 39 | { 40 | parent::__construct($name, $length, nullable: $nullable, comment: $comment); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /Database/Column/TinyBlob.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Database\Column; 22 | 23 | use Feast\Exception\DatabaseException; 24 | 25 | class TinyBlob extends Char 26 | { 27 | public const TYPE = 'TINYBLOB'; 28 | 29 | /** 30 | * Create TinyBlob column. 31 | * 32 | * @param string $name 33 | * @param null|positive-int $length 34 | * @param bool $nullable 35 | * @param string|null $comment 36 | * @throws DatabaseException 37 | */ 38 | public function __construct(string $name, ?int $length = null, bool $nullable = false, ?string $comment = null) 39 | { 40 | parent::__construct($name, $length, nullable: $nullable, comment: $comment); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /Database/Column/TinyInt.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Database\Column; 22 | 23 | use Feast\Exception\DatabaseException; 24 | 25 | class TinyInt extends Integer 26 | { 27 | public const TYPE = 'tinyint'; 28 | 29 | /** 30 | * Create TinyInt column. 31 | * 32 | * @param string $name 33 | * @param positive-int $length 34 | * @param bool $unsigned 35 | * @param bool $nullable 36 | * @param int|null $default 37 | * @param string|null $comment 38 | * @throws DatabaseException 39 | */ 40 | public function __construct(string $name, int $length = 3, bool $unsigned = false, bool $nullable = false, ?int $default = null, ?string $comment = null) 41 | { 42 | parent::__construct($name, $length, $unsigned, $nullable, $default, $comment); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Database/Column/TinyText.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Database\Column; 22 | 23 | use Feast\Exception\DatabaseException; 24 | 25 | class TinyText extends Char 26 | { 27 | public const TYPE = 'TINYTEXT'; 28 | 29 | /** 30 | * Create TinyText column. 31 | * 32 | * @param string $name 33 | * @param null|positive-int $length 34 | * @param bool $nullable 35 | * @param string|null $comment 36 | * @throws DatabaseException 37 | */ 38 | public function __construct(string $name, ?int $length = null, bool $nullable = false, ?string $comment = null) 39 | { 40 | parent::__construct($name, $length, nullable: $nullable, comment: $comment); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /Database/Column/VarChar.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Database\Column; 22 | 23 | use Feast\Exception\ServerFailureException; 24 | 25 | class VarChar extends Char 26 | { 27 | public const TYPE = 'VARCHAR'; 28 | 29 | /** 30 | * Create VarChar column. 31 | * 32 | * @param string $name 33 | * @param positive-int $length 34 | * @param bool $nullable 35 | * @param string|null $default 36 | * @param string|null $comment 37 | * @throws ServerFailureException 38 | */ 39 | public function __construct(string $name, int $length = 255, bool $nullable = false, ?string $default = null, ?string $comment = null) 40 | { 41 | parent::__construct($name, $length, $default,$nullable, $comment); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /Database/FieldDetails.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Database; 22 | 23 | use Feast\Controllers\CreateController; 24 | 25 | class FieldDetails 26 | { 27 | public function __construct( 28 | public string $name, 29 | public string $type, 30 | public string $phpType, 31 | public string $castType 32 | ) { 33 | } 34 | 35 | /** 36 | * Get model field string for template. 37 | * 38 | * @return string 39 | * @see CreateController::modelGet() 40 | * 41 | */ 42 | public function getModelField(): string 43 | { 44 | return ' public ' . $this->phpType . ' $' . $this->name . ";\n"; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Database/SQLiteQuery.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Database; 22 | 23 | /** 24 | * Query class specific to the SQLite Library 25 | */ 26 | class SQLiteQuery extends MySQLQuery 27 | { 28 | 29 | } 30 | -------------------------------------------------------------------------------- /Database/Table/Ddl.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Database\Table; 22 | 23 | use Feast\Date; 24 | 25 | class Ddl 26 | { 27 | /** 28 | * @param string $ddl 29 | * @param array $bindings 30 | */ 31 | public function __construct(public string $ddl, public array $bindings) 32 | { 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Database/TableDetails.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Database; 22 | 23 | class TableDetails 24 | { 25 | /** 26 | * TableDetails constructor. 27 | * 28 | * @param bool $compoundPrimary 29 | * @param string|null $primaryKeyType 30 | * @param string|null $primaryKey 31 | * @param array $fields 32 | * @param string|null $sequence 33 | */ 34 | public function __construct( 35 | public bool $compoundPrimary, 36 | public ?string $primaryKeyType, 37 | public ?string $primaryKey, 38 | public array $fields, 39 | public ?string $sequence = null 40 | ) { 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Deferred.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast; 22 | abstract class Deferred 23 | { 24 | protected bool $cancelled = false; 25 | abstract public function deferredAction(): void; 26 | 27 | public function __destruct() 28 | { 29 | if ( $this->cancelled === false ) { 30 | $this->deferredAction(); 31 | } 32 | } 33 | 34 | /** 35 | * Cancel this deferred call. 36 | * @return void 37 | */ 38 | public final function cancelDeferral(): void 39 | { 40 | $this->cancelled = true; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /DeferredCall.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast; 22 | class DeferredCall extends Deferred 23 | { 24 | protected bool $cancelled = false; 25 | 26 | /** @var callable|null $callable */ 27 | protected $callable = null; 28 | public function deferredAction(): void { 29 | /** @var callable $callable */ 30 | $callable = $this->callable; 31 | $callable(); 32 | } 33 | 34 | public function __construct(callable $callable) 35 | { 36 | $this->callable = $callable; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /DependencyInjector.php: -------------------------------------------------------------------------------- 1 | get($className, ...$arguments); 30 | } 31 | -------------------------------------------------------------------------------- /Email/Recipient.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Email; 22 | 23 | class Recipient 24 | { 25 | 26 | public function __construct(private string $email, private ?string $name = null) 27 | { 28 | } 29 | 30 | /** 31 | * Gets email address formatted for To/From/CC/BCC blocks. 32 | * 33 | * @return string 34 | */ 35 | public function getFormattedAddress(): string 36 | { 37 | $return = $this->name ?? $this->email; 38 | $return .= ' <' . $this->email . '>'; 39 | 40 | return $return; 41 | } 42 | 43 | /** 44 | * Get email address. 45 | * 46 | * @return string 47 | */ 48 | public function getEmail(): string 49 | { 50 | return $this->email; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /Enums/CollectionSort.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Enums; 22 | 23 | enum CollectionSort: int 24 | { 25 | case KEY = 1; 26 | case KEY_REVERSE = 2; 27 | case VALUE = 3; 28 | case VALUE_REVERSE = 4; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /Enums/DatabaseType.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Enums; 22 | 23 | enum DatabaseType: string 24 | { 25 | case MYSQL = 'mysql'; 26 | case SQLITE = 'sqlite'; 27 | case POSTGRES = 'postgres'; 28 | } 29 | -------------------------------------------------------------------------------- /Enums/DocType.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Enums; 22 | 23 | enum DocType: string 24 | { 25 | case HTML_4_01_FRAMESET = 'html401frame'; 26 | case HTML_4_01_STRICT = 'html401strict'; 27 | case HTML_4_01_TRANSITIONAL = 'html401transitional'; 28 | case HTML_5 = 'html5'; 29 | case XHTML_1_0_FRAMESET = 'xhtml1frame'; 30 | case XHTML_1_0_STRICT = 'xhtml1strict'; 31 | case XHTML_1_0_TRANSITIONAL = 'xhtml1transitional'; 32 | case XHTML_1_1 = 'xhtml11'; 33 | } 34 | -------------------------------------------------------------------------------- /Enums/LogLevelCode.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Enums; 22 | 23 | enum LogLevelCode: int 24 | { 25 | case DEBUG = 7; //LOG_DEBUG; 26 | case INFO = 6; // LOG_INFO; 27 | case NOTICE = 5; //LOG_NOTICE; 28 | case WARNING = 4; //LOG_WARNING; 29 | case ERROR = 3; //LOG_ERR; 30 | case CRITICAL = 2; //LOG_CRIT; 31 | case ALERT = 1; //LOG_ALERT; 32 | case EMERGENCY = 0; //LOG_EMERG; 33 | 34 | } 35 | -------------------------------------------------------------------------------- /Enums/ParamType.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Enums; 22 | 23 | enum ParamType 24 | { 25 | case FLAG; 26 | case PARAM; 27 | } 28 | -------------------------------------------------------------------------------- /Enums/RequestMethod.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Enums; 22 | 23 | enum RequestMethod: string 24 | { 25 | case GET = 'GET'; 26 | case POST = 'POST'; 27 | case PUT = 'PUT'; 28 | case PATCH = 'PATCH'; 29 | case DELETE = 'DELETE'; 30 | } 31 | -------------------------------------------------------------------------------- /Enums/ServiceContainer.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Enums; 22 | 23 | enum ServiceContainer: string 24 | { 25 | // This flag should only be used when running unit tests and needing to add mock items. 26 | // Use at your own risk. Better yet, don't use it at all. Ever. Not even for fun. Nope. 27 | case CLEAR_CONTAINER = 'clear'; 28 | } 29 | -------------------------------------------------------------------------------- /Exception/BadRequestException.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Exception; 22 | 23 | class BadRequestException extends ServerFailureException 24 | { 25 | 26 | } 27 | -------------------------------------------------------------------------------- /Exception/ConfigException.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Exception; 22 | 23 | class ConfigException extends ServerFailureException 24 | { 25 | 26 | } 27 | -------------------------------------------------------------------------------- /Exception/CurlException.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Exception; 22 | 23 | class CurlException extends ServerFailureException 24 | { 25 | 26 | } 27 | -------------------------------------------------------------------------------- /Exception/DatabaseException.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Exception; 22 | 23 | class DatabaseException extends ServerFailureException 24 | { 25 | 26 | } 27 | -------------------------------------------------------------------------------- /Exception/Error404Exception.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Exception; 22 | 23 | use Feast\Enums\ResponseCode; 24 | use Throwable; 25 | 26 | class Error404Exception extends ServerFailureException 27 | { 28 | 29 | public function __construct(string $message, int $errorCode = 0, Throwable $previousException = null) 30 | { 31 | parent::__construct($message, ResponseCode::HTTP_CODE_404, $errorCode, $previousException); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /Exception/InvalidArgumentException.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | 22 | namespace Feast\Exception; 23 | 24 | 25 | class InvalidArgumentException extends ServerFailureException 26 | { 27 | 28 | } 29 | -------------------------------------------------------------------------------- /Exception/InvalidDateException.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Exception; 22 | 23 | use Feast\Enums\ResponseCode; 24 | use Throwable; 25 | 26 | class InvalidDateException extends ServerFailureException 27 | { 28 | 29 | public function __construct( 30 | string $message, 31 | ?ResponseCode $responseCode = null, 32 | int $errorCode = 0, 33 | Throwable $previousException = null 34 | ) { 35 | parent::__construct($message, $responseCode, $errorCode, $previousException); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Exception/InvalidOptionException.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Exception; 22 | 23 | class InvalidOptionException extends ServerFailureException 24 | { 25 | 26 | } 27 | -------------------------------------------------------------------------------- /Exception/NotFoundException.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Exception; 22 | 23 | class NotFoundException extends ServerFailureException 24 | { 25 | 26 | } 27 | -------------------------------------------------------------------------------- /Exception/RouteException.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Exception; 22 | 23 | class RouteException extends ServerFailureException 24 | { 25 | 26 | } 27 | -------------------------------------------------------------------------------- /Exception/SessionNotStartedException.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Exception; 22 | 23 | class SessionNotStartedException extends ServerFailureException 24 | { 25 | 26 | } 27 | -------------------------------------------------------------------------------- /Exception/ThrottleException.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Exception; 22 | 23 | use Feast\Enums\ResponseCode; 24 | use Throwable; 25 | 26 | class ThrottleException extends ServerFailureException 27 | { 28 | 29 | public function __construct(string $message, int $errorCode = 0, Throwable $previousException = null) 30 | { 31 | parent::__construct($message, ResponseCode::HTTP_CODE_429, $errorCode, $previousException); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /FeastTests/Attributes/ActionTest.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Attributes; 22 | 23 | use Feast\Attributes\Action; 24 | use PHPUnit\Framework\TestCase; 25 | 26 | class ActionTest extends TestCase 27 | { 28 | public function testGetHelpText(): void 29 | { 30 | $action = new Action(description: 'Testing'); 31 | $this->assertEquals('Usage: php famine test:test', $action->getHelpText('php famine', 'test:test')); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /FeastTests/Attributes/ParamTest.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Attributes; 22 | 23 | use Feast\Attributes\Param; 24 | use Feast\Enums\ParamType; 25 | use Feast\Terminal; 26 | use PHPUnit\Framework\TestCase; 27 | 28 | class ParamTest extends TestCase 29 | { 30 | public function testGetParamText(): void 31 | { 32 | $param = new Param('string', 'test', 'Testing the attribute'); 33 | $this->assertEquals('{test} string Testing the attribute', $param->getParamText(new Terminal(false))); 34 | } 35 | 36 | public function testGetParamTextFlag(): void 37 | { 38 | $param = new Param('string', 'test', 'Testing the attribute', ParamType::FLAG); 39 | $this->assertEquals('--test=string Testing the attribute', $param->getParamText(new Terminal(false))); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /FeastTests/AutoloaderTest.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | declare(strict_types=1); 19 | 20 | use Feast\Autoloader; 21 | use PHPUnit\Framework\TestCase; 22 | 23 | class AutoloaderTest extends TestCase 24 | { 25 | 26 | public function testRegister(): void 27 | { 28 | $autoloader = new Autoloader(); 29 | $autoloader->register(); 30 | $this->assertInstanceOf(Autoloader::class,$autoloader); 31 | unset($autoloader); 32 | } 33 | 34 | public function testLoadClassFail(): void 35 | { 36 | $autoloader = new Autoloader(); 37 | $autoloader->loadClass('NonExistent'); 38 | $this->assertInstanceOf(Autoloader::class,$autoloader); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /FeastTests/Controllers/EmptyCliController.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | declare(strict_types=1); 19 | 20 | namespace Controllers; 21 | 22 | use Feast\CliController; 23 | 24 | class EmptyCliController extends CliController 25 | { 26 | 27 | } 28 | -------------------------------------------------------------------------------- /FeastTests/Controllers/EmptyController.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | declare(strict_types=1); 19 | 20 | namespace Controllers; 21 | 22 | use Feast\HttpController; 23 | 24 | class EmptyController extends HttpController { 25 | 26 | } 27 | -------------------------------------------------------------------------------- /FeastTests/Database/Column/BlobTest.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Database\Column; 22 | 23 | use Feast\Database\Column\Blob; 24 | use PHPUnit\Framework\TestCase; 25 | 26 | class BlobTest extends TestCase 27 | { 28 | 29 | public function testCreate(): void 30 | { 31 | $column = new Blob('test'); 32 | $this->assertInstanceOf(Blob::class,$column); 33 | } 34 | 35 | public function testGetLength(): void 36 | { 37 | $column = new Blob('Test', 100); 38 | $this->assertEquals(100, $column->getLength()); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /FeastTests/Database/Column/CharTest.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Database\Column; 22 | 23 | use Feast\Database\Column\Char; 24 | use PHPUnit\Framework\TestCase; 25 | 26 | class CharTest extends TestCase 27 | { 28 | 29 | public function testCreate(): void 30 | { 31 | $column = new Char('Test', 255); 32 | $this->assertInstanceOf(Char::class,$column); 33 | } 34 | 35 | public function testGetUnsignedNonNumeric(): void 36 | { 37 | $column = new Char('Test', 255); 38 | $this->assertEquals('', $column->getUnsignedText()); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /FeastTests/Database/Column/LongBlobTest.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Database\Column; 22 | 23 | use Feast\Database\Column\LongBlob; 24 | use PHPUnit\Framework\TestCase; 25 | 26 | class LongBlobTest extends TestCase 27 | { 28 | 29 | public function testCreate(): void 30 | { 31 | $column = new LongBlob('test'); 32 | $this->assertInstanceOf(LongBlob::class,$column); 33 | } 34 | 35 | public function testGetLength(): void 36 | { 37 | $column = new LongBlob('Test', 100); 38 | $this->assertEquals(100, $column->getLength()); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /FeastTests/Database/Column/LongTextTest.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Database\Column; 22 | 23 | use Feast\Database\Column\LongText; 24 | use PHPUnit\Framework\TestCase; 25 | 26 | class LongTextTest extends TestCase 27 | { 28 | 29 | public function testCreate(): void 30 | { 31 | $column = new LongText('test'); 32 | $this->assertInstanceOf(LongText::class,$column); 33 | } 34 | 35 | public function testGetLength(): void 36 | { 37 | $column = new LongText('Test', 4_000_000_000); 38 | $this->assertEquals(4_000_000_000, $column->getLength()); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /FeastTests/Database/Column/MediumBlobTest.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Database\Column; 22 | 23 | use Feast\Database\Column\MediumBlob; 24 | use PHPUnit\Framework\TestCase; 25 | 26 | class MediumBlobTest extends TestCase 27 | { 28 | 29 | public function testCreate(): void 30 | { 31 | $column = new MediumBlob('test'); 32 | $this->assertInstanceOf(MediumBlob::class,$column); 33 | } 34 | 35 | public function testGetLength(): void 36 | { 37 | $column = new MediumBlob('Test', 100); 38 | $this->assertEquals(100, $column->getLength()); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /FeastTests/Database/Column/MediumIntTest.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Database\Column; 22 | 23 | use Feast\Database\Column\MediumInt; 24 | use PHPUnit\Framework\TestCase; 25 | 26 | class MediumIntTest extends TestCase 27 | { 28 | 29 | public function testCreate(): void 30 | { 31 | $column = new MediumInt('Test', unsigned: true); 32 | $this->assertEquals('mediumint', $column->getType()); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /FeastTests/Database/Column/MediumTextTest.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Database\Column; 22 | 23 | use Feast\Database\Column\MediumText; 24 | use PHPUnit\Framework\TestCase; 25 | 26 | class MediumTextTest extends TestCase 27 | { 28 | 29 | public function testCreate(): void 30 | { 31 | $column = new MediumText('test'); 32 | $this->assertInstanceOf(MediumText::class,$column); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /FeastTests/Database/Column/SmallIntTest.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Database\Column; 22 | 23 | use Feast\Database\Column\SmallInt; 24 | use PHPUnit\Framework\TestCase; 25 | 26 | class SmallIntTest extends TestCase 27 | { 28 | 29 | public function testCreate(): void 30 | { 31 | $column = new SmallInt('Test', unsigned: true); 32 | $this->assertEquals('smallint', $column->getType()); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /FeastTests/Database/Column/TextTest.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Database\Column; 22 | 23 | use Feast\Database\Column\Text; 24 | use PHPUnit\Framework\TestCase; 25 | 26 | class TextTest extends TestCase 27 | { 28 | 29 | public function testCreate(): void 30 | { 31 | $column = new Text('test'); 32 | $this->assertInstanceOf(Text::class,$column); 33 | } 34 | 35 | public function testGetLength(): void 36 | { 37 | $column = new Text('Test', 100); 38 | $this->assertEquals(100, $column->getLength()); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /FeastTests/Database/Column/TinyBlobTest.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Database\Column; 22 | 23 | use Feast\Database\Column\TinyBlob; 24 | use PHPUnit\Framework\TestCase; 25 | 26 | class TinyBlobTest extends TestCase 27 | { 28 | 29 | public function testCreate(): void 30 | { 31 | $column = new TinyBlob('test'); 32 | $this->assertInstanceOf(TinyBlob::class,$column); 33 | } 34 | 35 | public function testGetLength(): void 36 | { 37 | $column = new TinyBlob('Test', 4); 38 | $this->assertEquals(4, $column->getLength()); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /FeastTests/Database/Column/TinyIntTest.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Database\Column; 22 | 23 | use Feast\Database\Column\TinyInt; 24 | use PHPUnit\Framework\TestCase; 25 | 26 | class TinyIntTest extends TestCase 27 | { 28 | 29 | public function testCreate(): void 30 | { 31 | $column = new TinyInt('Test', unsigned: true); 32 | $this->assertEquals('tinyint', $column->getType()); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /FeastTests/Database/Column/TinyTextTest.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Database\Column; 22 | 23 | use Feast\Database\Column\TinyText; 24 | use PHPUnit\Framework\TestCase; 25 | 26 | class TinyTextTest extends TestCase 27 | { 28 | 29 | public function testCreate(): void 30 | { 31 | $column = new TinyText('test'); 32 | $this->assertInstanceOf(TinyText::class,$column); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /FeastTests/Database/Column/VarCharTest.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Database\Column; 22 | 23 | use Feast\Database\Column\VarChar; 24 | use PHPUnit\Framework\TestCase; 25 | 26 | class VarCharTest extends TestCase 27 | { 28 | 29 | public function testCreate(): void 30 | { 31 | $column = new VarChar('Test', 255); 32 | $this->assertInstanceOf(VarChar::class,$column); 33 | } 34 | 35 | public function testComment(): void 36 | { 37 | $column = new VarChar('Test', 255, comment: 'This is a comment'); 38 | $this->assertEquals('This is a comment', $column->getComment()); 39 | } 40 | 41 | 42 | 43 | } 44 | -------------------------------------------------------------------------------- /FeastTests/Email/RecipientTest.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Email; 22 | 23 | use Feast\Email\Recipient; 24 | use PHPUnit\Framework\TestCase; 25 | 26 | class RecipientTest extends TestCase 27 | { 28 | 29 | public function testGetFormattedAddress(): void 30 | { 31 | $recipient = new Recipient('test@example.com', 'Test User'); 32 | $this->assertEquals('Test User ', $recipient->getFormattedAddress()); 33 | } 34 | 35 | public function testGetEmail(): void 36 | { 37 | $recipient = new Recipient('test@example.com', 'Test User'); 38 | $this->assertEquals('test@example.com', $recipient->getEmail()); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /FeastTests/Email/test.txt: -------------------------------------------------------------------------------- 1 | testing -------------------------------------------------------------------------------- /FeastTests/Exception/Error404ExceptionTest.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Exception; 22 | 23 | use Feast\Exception\Error404Exception; 24 | use Feast\Exception\ServerFailureException; 25 | use PHPUnit\Framework\TestCase; 26 | 27 | class Error404ExceptionTest extends TestCase 28 | { 29 | 30 | public function testCreate(): void 31 | { 32 | $exception = new Error404Exception('Testing'); 33 | $this->assertTrue( 34 | $exception instanceof Error404Exception && $exception instanceof ServerFailureException && $exception instanceof \Exception 35 | ); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /FeastTests/ExpectedOutputs/testCreateModelCompoundPrimary.txt: -------------------------------------------------------------------------------- 1 | User.php 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | declare(strict_types=1); 19 | 20 | namespace Mapper; 21 | 22 | use Feast\BaseMapper; 23 | use Model\Migration; 24 | 25 | class MigrationMapper extends BaseMapper 26 | { 27 | protected const OBJECT_NAME = Migration::class; 28 | protected const PRIMARY_KEY = 'primary_id'; 29 | public const TABLE_NAME = 'migrations'; 30 | } 31 | -------------------------------------------------------------------------------- /FeastTests/Migrations/migration1_migrations.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | declare(strict_types=1); 19 | 20 | namespace Migrations; 21 | 22 | use Feast\Database\Migration; 23 | 24 | class migration1_migrations extends Migration 25 | { 26 | 27 | protected const NAME = 'Migrations'; 28 | 29 | public function up(): void 30 | { 31 | parent::up(); 32 | } 33 | 34 | public function down(): void 35 | { 36 | parent::down(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /FeastTests/Migrations/migration2_test.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | declare(strict_types=1); 19 | 20 | namespace Migrations; 21 | 22 | use Feast\Database\Migration; 23 | 24 | class migration2_test extends Migration 25 | { 26 | 27 | protected const NAME = 'Test'; 28 | 29 | public function up(): void 30 | { 31 | parent::up(); 32 | } 33 | 34 | public function down(): void 35 | { 36 | parent::down(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /FeastTests/Migrations/migration3_blowup.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | declare(strict_types=1); 19 | 20 | namespace Migrations; 21 | 22 | use Feast\Database\Migration; 23 | 24 | class migration3_blowup extends Migration 25 | { 26 | 27 | protected const NAME = 'Blowup'; 28 | 29 | public function up(): void 30 | { 31 | throw new \PDOException('Blew up'); 32 | } 33 | 34 | public function down(): void 35 | { 36 | parent::down(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /FeastTests/Mocks/BadJsonItem.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Mocks; 22 | 23 | use Feast\Attributes\JsonItem; 24 | 25 | /** 26 | * @psalm-suppress all 27 | */ 28 | class BadJsonItem 29 | { 30 | #[JsonItem(name: 'first_name')] 31 | public string $firstName; 32 | #[JsonItem(name: 'last_name')] 33 | public string $lastName; 34 | 35 | public function __construct(string $explodesBecauseNotPassed) 36 | { 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /FeastTests/Mocks/DeferredMock.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Mocks; 22 | 23 | use Feast\Deferred; 24 | 25 | class DeferredMock extends Deferred 26 | { 27 | 28 | public function __construct(public string $echo) 29 | { 30 | 31 | } 32 | 33 | public function deferredAction(): void 34 | { 35 | echo $this->echo; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /FeastTests/Mocks/FormClassFileFunctions.mock: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Form; 22 | 23 | function getimagesize($file) 24 | { 25 | 26 | if ( str_contains($file,'failure') ) { return false; } 27 | return true; 28 | } 29 | -------------------------------------------------------------------------------- /FeastTests/Mocks/FormValidatorsFileFunctions.mock: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Form\Validator; 22 | 23 | function getimagesize($file) 24 | { 25 | 26 | if ( str_contains($file,'failure') ) { return false; } 27 | return true; 28 | } 29 | -------------------------------------------------------------------------------- /FeastTests/Mocks/InjectedMock.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Mocks; 22 | 23 | class InjectedMock { 24 | use \Feast\Traits\DependencyInjected; 25 | 26 | public function __construct() 27 | { 28 | $this->checkInjected(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /FeastTests/Mocks/MigrationMock.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Mocks; 22 | 23 | use Feast\Database\Migration; 24 | 25 | /** 26 | * Class MigrationMock extends Migration. 27 | * This class is solely to be used to test functions in the Database class. 28 | * DO NOT USE IN PRODUCTION AS NO QUERIES WILL BE EXECUTED! 29 | */ 30 | class MigrationMock extends Migration 31 | { 32 | public const CONNECTION = 'default'; 33 | protected const NAME = 'testMigration'; 34 | } 35 | -------------------------------------------------------------------------------- /FeastTests/Mocks/MigrationMockNoConnection.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Mocks; 22 | 23 | use Feast\Database\Migration; 24 | 25 | /** 26 | * Class MigrationMock extends Migration. 27 | * This class is solely to be used to test functions in the Database class. 28 | * DO NOT USE IN PRODUCTION AS NO QUERIES WILL BE EXECUTED! 29 | */ 30 | class MigrationMockNoConnection extends Migration 31 | { 32 | public const CONNECTION = null; 33 | protected const NAME = 'testMigration'; 34 | } 35 | -------------------------------------------------------------------------------- /FeastTests/Mocks/MigrationMockNoName.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Mocks; 22 | 23 | use Feast\Database\Migration; 24 | 25 | /** 26 | * Class MigrationMock extends Migration. 27 | * This class is solely to be used to test functions in the Database class. 28 | * DO NOT USE IN PRODUCTION AS NO QUERIES WILL BE EXECUTED! 29 | */ 30 | class MigrationMockNoName extends Migration 31 | { 32 | public const CONNECTION = 'default'; 33 | } 34 | -------------------------------------------------------------------------------- /FeastTests/Mocks/MockBaseMapper.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Mocks; 22 | 23 | use Feast\BaseMapper; 24 | use Feast\BaseModel; 25 | 26 | class MockBaseMapper extends BaseMapper 27 | { 28 | public const TABLE_NAME = 'TestTable'; 29 | protected const OBJECT_NAME = MockBaseModel::class; 30 | protected const PRIMARY_KEY = 'id'; 31 | 32 | public function findByPrimaryKey(int|string $value, bool $validate = false): ?BaseModel 33 | { 34 | if ($value === 'MAINTEST') { 35 | return new MockBaseModel(); 36 | } 37 | return parent::findByPrimaryKey($value, $validate); // TODO: Change the autogenerated stub 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /FeastTests/Mocks/MockBaseModel.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Mocks; 22 | 23 | use Feast\BaseModel; 24 | use Feast\Date; 25 | 26 | class MockBaseModel extends BaseModel 27 | { 28 | protected const MAPPER_NAME = MockBaseMapper::class; 29 | 30 | public null|int|string $id = null; 31 | public ?Date $theDate = null; 32 | public ?string $theName = null; 33 | public ?string $theNull = null; 34 | public ?\stdClass $theThing = null; 35 | public ?string $passEncrypted = null; 36 | public ?bool $theTruth = null; 37 | public ?bool $theUnTruth = null; 38 | public ?bool $theUnknown = null; 39 | public ?bool $theNumericTruth = null; 40 | public ?bool $theNumericUnTruth = null; 41 | } 42 | -------------------------------------------------------------------------------- /FeastTests/Mocks/MockBaseModelNoMapper.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Mocks; 22 | 23 | class MockBaseModelNoMapper extends MockBaseModel { 24 | protected const MAPPER_NAME = null; 25 | } 26 | -------------------------------------------------------------------------------- /FeastTests/Mocks/MockCronJob.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Mocks; 22 | 23 | use Feast\Date; 24 | use Feast\Interfaces\ConfigInterface; 25 | use Feast\Interfaces\JobInterface; 26 | use Feast\Jobs\CronJob; 27 | 28 | class MockCronJob extends CronJob implements JobInterface 29 | { 30 | 31 | public function run(): bool 32 | { 33 | throw new \Exception('Testing exceptions'); 34 | } 35 | 36 | public function shouldRun(Date $now, ConfigInterface $config): bool 37 | { 38 | return true; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /FeastTests/Mocks/MockJob.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Mocks; 22 | 23 | use Feast\Interfaces\JobInterface; 24 | use Feast\Jobs\QueueableJob; 25 | 26 | class MockJob extends QueueableJob implements JobInterface 27 | { 28 | 29 | public function run(): bool 30 | { 31 | return true; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /FeastTests/Mocks/MockUser.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Mocks; 22 | 23 | use Feast\BaseModel; 24 | 25 | class MockUser extends BaseModel { 26 | public ?string $user = null; 27 | } 28 | -------------------------------------------------------------------------------- /FeastTests/Mocks/ProfilerFunctions.mock: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Profiler; 22 | 23 | function microtime($float) { 24 | return ProfilerSetting::$microTime ?? 1613250123.1; 25 | } 26 | 27 | function memory_get_peak_usage(bool $real) { 28 | return $real ? 10242097153 : 1024442285; 29 | } 30 | 31 | function memory_get_usage(bool $real) { 32 | return $real ? 10242097153 : 1024404625; 33 | } 34 | 35 | function function_exists($function) { 36 | return ProfilerSetting::$useBcMath; 37 | } 38 | 39 | class ProfilerSetting { 40 | public static bool $useBcMath = true; 41 | public static ?float $microTime = null; 42 | 43 | public static function reset(): void 44 | { 45 | self::$useBcMath = true; 46 | self::$microTime = null; 47 | } 48 | } -------------------------------------------------------------------------------- /FeastTests/Mocks/README.md: -------------------------------------------------------------------------------- 1 | ### DO NOT USE THESE CLASSES 2 | These classes are meant for simulation use in the FeastTests folder only. Your application will not run correctly. -------------------------------------------------------------------------------- /FeastTests/Mocks/SampleResponses/GetHtml.txt: -------------------------------------------------------------------------------- 1 | HTTP/1.1 200 OK 2 | Date: Sun, 31 Jan 2021 00:31:57 GMT 3 | Server: Apache/2.4.18 (Ubuntu) 4 | Set-Cookie: user=mdmpd0d58gqpktf10h4dt67dkc; path=/ 5 | Set-Cookie: userexpired=mdmpd0d58gqpktf10h4dt67dkc; path=/; expires=1 6 | Expires: Thu, 19 Nov 1981 08:52:00 GMT 7 | Cache-Control: no-store, no-cache, must-revalidate 8 | Pragma: no-cache 9 | Vary: Accept-Encoding 10 | Transfer-Encoding: chunked 11 | Content-Type: text/html; charset=UTF-8 12 | 13 | 14 | 15 | 16 | 17 | Feast Framework 18 | 19 | 20 | Test 21 | 22 | 23 | -------------------------------------------------------------------------------- /FeastTests/Mocks/SampleResponses/GetJson.txt: -------------------------------------------------------------------------------- 1 | HTTP/1.1 200 OK 2 | Date: Sun, 31 Jan 2021 00:31:57 GMT 3 | Server: Apache/2.4.18 (Ubuntu) 4 | Set-Cookie: user=mdmpd0d58gqpktf10h4dt67dkc; path=/ 5 | Expires: Thu, 19 Nov 1981 08:52:00 GMT 6 | Cache-Control: no-store, no-cache 7 | Cache-Control: must-revalidate 8 | Pragma: no-cache 9 | Vary: Accept-Encoding 10 | Transfer-Encoding: chunked 11 | Content-Type: application/json; charset=UTF-8 12 | 13 | { 14 | "test":"feast" 15 | } -------------------------------------------------------------------------------- /FeastTests/Mocks/SampleResponses/GetXml.txt: -------------------------------------------------------------------------------- 1 | HTTP/1.1 200 OK 2 | Date: Sun, 31 Jan 2021 00:31:57 GMT 3 | Server: Apache/2.4.18 (Ubuntu) 4 | Set-Cookie: user=mdmpd0d58gqpktf10h4dt67dkc; path=/ 5 | Set-Cookie: userexpired=mdmpd0d58gqpktf10h4dt67dkc; path=/; expires=1 6 | Expires: Thu, 19 Nov 1981 08:52:00 GMT 7 | Cache-Control: no-store, no-cache, must-revalidate 8 | Pragma: no-cache 9 | Vary: Accept-Encoding 10 | Transfer-Encoding: chunked 11 | Content-Type: text/html; charset=UTF-8 12 | 13 | 14 | 15 | 16 | Feast Framework 17 | 18 | 19 | Test 20 | 21 | 22 | -------------------------------------------------------------------------------- /FeastTests/Mocks/SampleResponses/SimpleGetHtml.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Feast Framework 6 | 7 | 8 | Test 9 | 10 | 11 | -------------------------------------------------------------------------------- /FeastTests/Mocks/SecondItem.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Mocks; 22 | 23 | use Feast\Attributes\JsonItem; 24 | 25 | /** 26 | * @psalm-suppress all 27 | */ 28 | class SecondItem 29 | { 30 | #[JsonItem(name: 'also_first_name')] 31 | public string $firstName; 32 | #[JsonItem(name: 'also_last_name')] 33 | public string $lastName; 34 | 35 | public function __construct() 36 | { 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /FeastTests/Mocks/SessionFunctions.mock: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Session; 22 | 23 | function session_name(string $name) 24 | { 25 | MockSession::$name = $name; 26 | } 27 | 28 | function session_set_cookie_params(int $params) 29 | { 30 | } 31 | 32 | function session_start() 33 | { 34 | } 35 | 36 | function session_destroy() 37 | { 38 | MockSession::reset(); 39 | } 40 | 41 | class MockSession 42 | { 43 | public static ?string $name = null; 44 | 45 | public static function reset(): void 46 | { 47 | self::$name = null; 48 | $_SESSION = []; 49 | $_SERVER['REMOTE_ADDR'] = '127.0.0.1'; 50 | $_SERVER['REQUEST_URI'] = '/index'; 51 | } 52 | } -------------------------------------------------------------------------------- /FeastTests/Model/Job.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Model; 22 | 23 | use \Feast\BaseModel; 24 | use Feast\Date; 25 | use Mapper\MigrationMapper; 26 | 27 | class Migration extends BaseModel 28 | { 29 | protected const MAPPER_NAME = MigrationMapper::class; 30 | 31 | public string|int $primary_id = 1; 32 | public string $migration_id = ''; 33 | public ?Date $last_up = null; 34 | public ?Date $last_down = null; 35 | public ?string $status = null; 36 | public string $name = ''; 37 | 38 | public function recordUp(): void 39 | { 40 | $this->last_up = Date::createFromNow(); 41 | $this->status = 'up'; 42 | $this->save(); 43 | } 44 | 45 | public function recordDown(): void 46 | { 47 | $this->last_down = Date::createFromNow(); 48 | $this->status = 'down'; 49 | $this->save(); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /FeastTests/Modules/CLI/Controllers/IndexController.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Modules\CLI\Controllers; 22 | 23 | use Feast\Attributes\Action; 24 | use Feast\Attributes\Param; 25 | use Feast\Enums\ParamType; 26 | 27 | class IndexController 28 | { 29 | #[Action(description: 'Testing Helps')] 30 | #[Param(type: 'string', name: 'name', description: 'Name of service to create')] 31 | #[Param(type: 'string', name: 'potato', description: 'A random color', paramType: ParamType::FLAG)] 32 | public function indexGet( 33 | string $name, 34 | string $color 35 | ): void { 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /FeastTests/Modules/CLI/Controllers/SmallController.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Modules\CLI\Controllers; 22 | 23 | use Feast\Attributes\Action; 24 | use Feast\Attributes\Param; 25 | use Feast\Enums\ParamType; 26 | 27 | class SmallController 28 | { 29 | #[Action(description: 'Testing Helps')] 30 | #[Param(type: 'string', name: 'name', description: 'Name of service to create')] 31 | #[Param(type: 'string', name: 'color', description: 'A random color', paramType: ParamType::FLAG)] 32 | public function createGet( 33 | string $name, 34 | string $color 35 | ): void { 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /FeastTests/Modules/Test/Controllers/FeastInitFailedController.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Modules\Test\Controllers; 22 | 23 | use Feast\HttpController; 24 | 25 | class FeastInitFailedController extends HttpController 26 | { 27 | public function init(): bool 28 | { 29 | return false; 30 | } 31 | 32 | public function serviceGet(): void 33 | { 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /FeastTests/NameHelperTest.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | declare(strict_types=1); 19 | 20 | use Feast\NameHelper; 21 | use PHPUnit\Framework\TestCase; 22 | 23 | class NameHelperTest extends TestCase 24 | { 25 | 26 | public function testGetAction(): void 27 | { 28 | $action = 'test-run'; 29 | $this->assertEquals('testRunAction', NameHelper::getDefaultAction($action)); 30 | } 31 | 32 | public function testGetName(): void 33 | { 34 | $genericName = 'test-run'; 35 | $this->assertEquals('TestRun', NameHelper::getName($genericName)); 36 | } 37 | 38 | public function testGetController(): void 39 | { 40 | $controller = 'test-run'; 41 | $this->assertEquals('TestRunController', NameHelper::getController($controller)); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /FeastTests/PluginTest.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | declare(strict_types=1); 19 | 20 | use Feast\Plugin; 21 | use Feast\View; 22 | use PHPUnit\Framework\TestCase; 23 | 24 | class PluginTest extends TestCase 25 | { 26 | 27 | public function testInit(): void 28 | { 29 | $view = $this->createStub(View::class); 30 | $plugin = $this->getMockForAbstractClass(Plugin::class, [$view]); 31 | 32 | $stubbedRouter = $this->createStub(\Feast\Interfaces\RouterInterface::class); 33 | $plugin->init($stubbedRouter); 34 | 35 | $this->assertInstanceOf(Plugin::class,$plugin); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /FeastTests/Plugins/TestPlugin.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Plugins; 22 | 23 | use Feast\Plugin; 24 | 25 | class TestPlugin extends Plugin 26 | { 27 | public function preDispatch(): void 28 | { 29 | } 30 | 31 | public function postDispatch(): void 32 | { 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /FeastTests/Plugins/ThrottleExceptionPlugin.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Plugins; 22 | 23 | use Feast\Exception\ThrottleException; 24 | use Feast\Plugin; 25 | 26 | class ThrottleExceptionPlugin extends Plugin 27 | { 28 | public function preDispatch(): void 29 | { 30 | } 31 | 32 | public function postDispatch(): void 33 | { 34 | throw new ThrottleException('Rate limit exceeded'); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /FeastTests/Views/Error/server-failure.phtml: -------------------------------------------------------------------------------- 1 | Something went wrong! If you are the administrator, check the error logs for more info.

-------------------------------------------------------------------------------- /FeastTests/Views/Test/Test.phtml: -------------------------------------------------------------------------------- 1 | This file is used by ViewTest.php to ensure the view class is behaving correctly. -------------------------------------------------------------------------------- /FeastTests/Views/layout.phtml: -------------------------------------------------------------------------------- 1 | This is a layout. 2 | -------------------------------------------------------------------------------- /FeastTests/config.ini: -------------------------------------------------------------------------------- 1 | ; THIS FILE IS USED FOR THE ConfigTest TEST RUNNER 2 | [production] 3 | test=1; 4 | database.default.name='feast'; 5 | database.default.user='feast_user'; 6 | database.default.password='dont_put_passwords_in_the_config_file'; 7 | [production : development] 8 | test=2; 9 | database.default.name='feasty'; 10 | database.default.user='dev_user'; -------------------------------------------------------------------------------- /FeastTests/config.local.ini: -------------------------------------------------------------------------------- 1 | ; THIS FILE IS USED FOR THE ConfigTest TEST RUNNER 2 | test2 = 'testing' 3 | database.default.password = 'this_is_secure' -------------------------------------------------------------------------------- /FeastTests/configs/config.local.php: -------------------------------------------------------------------------------- 1 | 'testing', 6 | 'database' => [ 7 | 'default' => [ 8 | 'password' => 'this_is_secure', 9 | 10 | ] 11 | ] 12 | 13 | ]; 14 | -------------------------------------------------------------------------------- /FeastTests/configs/config.php: -------------------------------------------------------------------------------- 1 | 1, 6 | 'database.default' => [ 7 | 'name' => 'feast', 8 | 'user' => 'feast_user', 9 | 'password' => 'dont_put_passwords_in_the_config_file', 10 | 11 | ], 12 | 'featureflags' => [ 13 | 'test' => new \Feast\Config\FeatureFlag(true), 14 | 'otherTest' => new \Feast\Config\FeatureFlag(false), 15 | 'trueTest' => new \Feast\Config\FeatureFlag(true), 16 | 'falseTest' => new \Feast\Config\FeatureFlag(false), 17 | ], 18 | 'log.path' => APPLICATION_ROOT . 'storage/logs/new', 19 | 'storage.path' => APPLICATION_ROOT . 'storage/temp/' 20 | ]; 21 | $environments['production:development'] = [ 22 | 'test' => 2, 23 | 'database' => [ 24 | 'default' => [ 25 | 'name' => 'feast', 26 | 'user' => 'feast_user' 27 | ] 28 | ], 29 | 'featureflags' => '' 30 | ]; 31 | 32 | $environments['production:features'] = [ 33 | 'featureflags' => [ 34 | 'trueTest' => new \Feast\Config\FeatureFlag(false), 35 | 'falseTest' => new \Feast\Config\FeatureFlag(true), 36 | ] 37 | ]; 38 | 39 | return $environments; 40 | -------------------------------------------------------------------------------- /FeastTests/githubphpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | . 6 | 7 | 8 | 9 | 10 | ../ 11 | 12 | 13 | ../FeastTests 14 | ../Install 15 | ../PsalmLoader.php 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /FeastTests/scheduled_jobs.php: -------------------------------------------------------------------------------- 1 | withoutOverlapping()->runInBackground(), 5 | 6 | ]; -------------------------------------------------------------------------------- /Form/Field/Checkbox.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Form\Field; 22 | 23 | class Checkbox extends CheckboxAndRadio 24 | { 25 | 26 | public const TYPE = 'checkbox'; 27 | 28 | public function __construct(string $name, ?string $formName = null, ?string $id = null) 29 | { 30 | parent::__construct($name, $formName, self::TYPE, $id); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /Form/Field/Radio.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Form\Field; 22 | 23 | class Radio extends CheckboxAndRadio 24 | { 25 | 26 | public const TYPE = 'radio'; 27 | 28 | public function __construct(string $name, ?string $formName = null, ?string $id = null) 29 | { 30 | parent::__construct($name, $formName, self::TYPE, $id); 31 | } 32 | 33 | /** 34 | * Set selected value to true. Always overwrites. 35 | * 36 | * @param string $value 37 | * @param bool $overwrite 38 | * @return static 39 | */ 40 | public function setValue(string $value, bool $overwrite = true): static 41 | { 42 | return parent::setValue($value); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /Form/Field/SelectValue.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | declare(strict_types=1); 19 | 20 | namespace Feast\Form\Field; 21 | 22 | class SelectValue 23 | { 24 | public ?string $id = null; 25 | 26 | public function __construct(public string $value, public string $label, public bool $selected = false) 27 | { 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Form/Field/Value.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | declare(strict_types=1); 19 | 20 | namespace Feast\Form\Field; 21 | 22 | use Feast\Form\Label; 23 | 24 | class Value 25 | { 26 | public function __construct( 27 | public string $value, 28 | public ?Label $label = null, 29 | public bool $selected = false, 30 | public ?string $id = null, 31 | public string $class = '', 32 | public string $attributes = '' 33 | ) { 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /Form/Filter/Filter.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Form\Filter; 22 | 23 | interface Filter 24 | { 25 | /** 26 | * Execute the filter and return new value. 27 | * 28 | * @param string $value 29 | * @return string 30 | */ 31 | public static function filter(string $value): string; 32 | 33 | } 34 | -------------------------------------------------------------------------------- /Form/Filter/Md5.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Form\Filter; 22 | 23 | class Md5 implements Filter 24 | { 25 | /** 26 | * Execute the filter and return new value. 27 | * 28 | * @param string $value 29 | * @return string 30 | */ 31 | public static function filter(string $value): string 32 | { 33 | return md5($value); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Form/Filter/Sha1.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Form\Filter; 22 | 23 | class Sha1 implements Filter 24 | { 25 | /** 26 | * Execute the filter and return new value. 27 | * 28 | * @param string $value 29 | * @return string 30 | */ 31 | public static function filter(string $value): string 32 | { 33 | return sha1($value, true); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Form/Filter/Trim.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Form\Filter; 22 | 23 | class Trim implements Filter 24 | { 25 | /** 26 | * Execute the filter and return new value. 27 | * 28 | * @param string $value 29 | * @return string 30 | */ 31 | public static function filter(string $value): string 32 | { 33 | return trim($value); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Form/Validator/Alphabetical.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Form\Validator; 22 | 23 | use Feast\Form\Field; 24 | 25 | class Alphabetical implements Validator 26 | { 27 | public static function validate( 28 | string $key, 29 | string $value, 30 | Field $field, 31 | array $files, 32 | array &$errors, 33 | bool $valid 34 | ): bool { 35 | if (!ctype_alpha($value)) { 36 | $errors[] = [$key, 'Alphabetical']; 37 | $valid = false; 38 | } 39 | return $valid; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /Form/Validator/Decimal.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Form\Validator; 22 | 23 | use Feast\Form\Field; 24 | 25 | class Decimal implements Validator 26 | { 27 | public static function validate( 28 | string $key, 29 | string $value, 30 | Field $field, 31 | array $files, 32 | array &$errors, 33 | bool $valid 34 | ): bool { 35 | if (!ctype_digit(str_replace('.', '', $value)) || substr_count( 36 | $value, 37 | '.' 38 | ) > 1) { 39 | $errors[] = [$key, 'Decimal']; 40 | $valid = false; 41 | } 42 | return $valid; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /Form/Validator/Validator.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Form\Validator; 22 | 23 | use Feast\Form\Field; 24 | 25 | interface Validator 26 | { 27 | /** 28 | * Validate a form field. 29 | * 30 | * Update the errors array (passed by reference) and 31 | * return $valid (passed in as parameter and potentially modified in validator). 32 | * 33 | * @param string $key 34 | * @param string $value 35 | * @param Field $field 36 | * @param array $files 37 | * @param array $errors 38 | * @param bool $valid 39 | * @return bool 40 | */ 41 | public static function validate( 42 | string $key, 43 | string $value, 44 | Field $field, 45 | array $files, 46 | array &$errors, 47 | bool $valid 48 | ): bool; 49 | 50 | } 51 | -------------------------------------------------------------------------------- /Install/.appenv: -------------------------------------------------------------------------------- 1 | production -------------------------------------------------------------------------------- /Install/Controllers/ErrorController.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Controllers; 20 | 21 | use Feast\HttpController; 22 | 23 | class ErrorController extends HttpController 24 | { 25 | 26 | public function fourohfourGet(): void 27 | { 28 | // TODO Add Content 29 | } 30 | 31 | public function rateLimitGet(): void 32 | { 33 | // TODO Add Content 34 | } 35 | 36 | public function serverFailureGet(): void 37 | { 38 | // TODO Add Content 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Install/Controllers/IndexController.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Controllers; 22 | 23 | use Feast\HttpController; 24 | 25 | class IndexController extends HttpController 26 | { 27 | 28 | public function indexGet(): void 29 | { 30 | // @todo create index 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /Install/Mapper/MigrationMapper.php.txt: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Mapper; 22 | 23 | use \Feast\BaseMapper; 24 | use Model\Migration; 25 | 26 | class MigrationMapper extends BaseMapper 27 | { 28 | protected const OBJECT_NAME = Migration::class; 29 | protected const PRIMARY_KEY = 'primary_id'; 30 | public const TABLE_NAME = 'migrations'; 31 | } -------------------------------------------------------------------------------- /Install/Migrations/migration1_migrations.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | declare(strict_types=1); 19 | 20 | namespace Migrations; 21 | 22 | use Feast\Database\Migration; 23 | use Feast\Database\Table\TableFactory; 24 | 25 | class migration1_migrations extends Migration 26 | { 27 | 28 | protected const NAME = 'Migrations'; 29 | 30 | public function up(): void 31 | { 32 | $table = TableFactory::getTable('migrations'); 33 | $table->autoIncrement('primary_id'); 34 | $table->varChar('migration_id'); 35 | $table->varChar('name'); 36 | $table->dateTime('last_up', nullable: true); 37 | $table->dateTime('last_down', nullable: true); 38 | $table->varChar('status'); 39 | $table->index('migration_id'); 40 | $table->create(); 41 | parent::up(); 42 | } 43 | 44 | public function down(): void 45 | { 46 | $table = TableFactory::getTable('migrations'); 47 | $table->drop(); 48 | parent::down(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Install/Migrations/migration2_jobs.php: -------------------------------------------------------------------------------- 1 | varChar('job_id') 19 | ->varChar('job_name') 20 | ->text('job_context') 21 | ->timestamp('created_at') 22 | ->dateTime('ran_at',null,true) 23 | ->varChar('status', default: 'pending') 24 | ->tinyInt('tries') 25 | ->tinyInt('max_tries') 26 | ->varChar('queue_name'); 27 | $table->create(); 28 | $this->connection->rawQuery('ALTER TABLE jobs add PRIMARY KEY (job_id)'); 29 | parent::up(); 30 | } 31 | 32 | public function down(): void 33 | { 34 | /** @todo Create down query */ 35 | TableFactory::getTable('jobs')->drop(); 36 | parent::down(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Install/Model/Job.php.txt: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Model; 22 | 23 | use \Feast\BaseModel; 24 | use Feast\Date; 25 | use Mapper\MigrationMapper; 26 | 27 | class Migration extends BaseModel 28 | { 29 | protected const MAPPER_NAME = MigrationMapper::class; 30 | 31 | public int $primary_id; 32 | public string $migration_id; 33 | public ?Date $last_up; 34 | public ?Date $last_down; 35 | public ?string $status; 36 | public string $name; 37 | 38 | public function recordUp(): void 39 | { 40 | $this->last_up = Date::createFromNow(); 41 | $this->status = 'up'; 42 | $this->save(); 43 | } 44 | 45 | public function recordDown(): void 46 | { 47 | $this->last_down = Date::createFromNow(); 48 | $this->status = 'down'; 49 | $this->save(); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Install/bin/router.php: -------------------------------------------------------------------------------- 1 | isEnabled; 21 | } 22 | 23 | } -------------------------------------------------------------------------------- /Install/bin/templates/Filter.php.txt: -------------------------------------------------------------------------------- 1 | connection->rawQuery('select 1'); 18 | parent::up(); 19 | } 20 | 21 | public function down() : void 22 | { 23 | /** @todo Create down query */ 24 | $this->connection->rawQuery('select 1'); 25 | parent::down(); 26 | } 27 | } -------------------------------------------------------------------------------- /Install/bin/templates/Model.php.txt: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | /* @var $this View */ 20 | 21 | use Feast\Interfaces\ConfigInterface; 22 | use Feast\Interfaces\ProfilerInterface; 23 | use Feast\View; 24 | 25 | echo $this->getDtd(); 26 | ?> 27 | 28 | 29 | getEncodingHtml(); ?> 30 | getTitle(); ?> 31 | getCss(); ?> 32 | getPreScripts(); ?> 33 | 34 | 35 | 37 | getPostScripts(); ?> 38 | getSetting('profiler')): ?> 40 |

41 | Total memory: getReadableMemoryUsage(); ?>
42 | Peak memory: getReadablePeakMemoryUsage(); ?>
43 | Page executed in getTotalTime(); ?> seconds. 44 |

45 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /Install/bootstrap.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | declare(strict_types=1); 19 | 20 | use Feast\Autoloader; 21 | use Feast\Interfaces\RouterInterface; 22 | 23 | $router = di(RouterInterface::class); 24 | if ($router->isFromCache() === false) { 25 | ################################################# 26 | # CUSTOM ROUTES GO HERE IF NOT USING ATTRIBUTES # 27 | ################################################# 28 | 29 | ##################### 30 | # END CUSTOM ROUTES # 31 | ##################### 32 | } 33 | $autoLoader = di(Autoloader::class); 34 | $autoLoader->addPathMapping('Psr', ['/vendor/Psr', '/Feast/Psr']); 35 | 36 | -------------------------------------------------------------------------------- /Install/composer-install.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | declare(strict_types=1); 19 | 20 | chdir(__DIR__); 21 | if ( !defined('APPLICATION_ROOT')) { 22 | define('APPLICATION_ROOT', __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR); 23 | } 24 | require_once('install.php'); 25 | -------------------------------------------------------------------------------- /Install/configs/config.local.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | #8972c5 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Install/public/icons/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FeastFramework/framework/63387eedde1b4caa8e1ad05bda27adeb072792b3/Install/public/icons/favicon-16x16.png -------------------------------------------------------------------------------- /Install/public/icons/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FeastFramework/framework/63387eedde1b4caa8e1ad05bda27adeb072792b3/Install/public/icons/favicon-32x32.png -------------------------------------------------------------------------------- /Install/public/icons/mstile-150x150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FeastFramework/framework/63387eedde1b4caa8e1ad05bda27adeb072792b3/Install/public/icons/mstile-150x150.png -------------------------------------------------------------------------------- /Install/public/icons/site.webmanifest: -------------------------------------------------------------------------------- 1 | { 2 | "name": "", 3 | "short_name": "", 4 | "icons": [ 5 | { 6 | "src": "/icons/android-chrome-192x192.png", 7 | "sizes": "192x192", 8 | "type": "image/png" 9 | }, 10 | { 11 | "src": "/icons/android-chrome-512x512.png", 12 | "sizes": "512x512", 13 | "type": "image/png" 14 | } 15 | ], 16 | "theme_color": "#ffffff", 17 | "background_color": "#ffffff", 18 | "display": "standalone" 19 | } 20 | -------------------------------------------------------------------------------- /Install/public/maintenance-screen.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Install/scheduled_jobs.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | # ┌───────────── minute (0 - 59) 19 | # │ ┌───────────── hour (0 - 23) 20 | # │ │ ┌───────────── day of the month (1 - 31) 21 | # │ │ │ ┌───────────── month (1 - 12) 22 | # │ │ │ │ ┌───────────── day of the week (0 - 6) (Sunday to Saturday; 23 | # │ │ │ │ │ 7 is also Sunday) 24 | # │ │ │ │ │ 25 | # │ │ │ │ │ 26 | # * * * * * 27 | return [ 28 | // (new \Jobs\Cron\TestCron()) 29 | // ->setEnv('development') 30 | // ->setCronString('* * * * *') 31 | // ->withoutOverlapping(2), 32 | // 33 | // (new \Jobs\Cron\TestCron()) 34 | // ->setCronString('* * * * *') 35 | // ->withoutOverlapping(), 36 | // 37 | // (new \Jobs\Cron\TestCron()) 38 | // ->setEnv('development') 39 | // ->setCronString('* * * * *') 40 | ]; 41 | -------------------------------------------------------------------------------- /Interfaces/ControllerInterface.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Interfaces; 22 | 23 | /** 24 | * 25 | * Class to load and manage the configuration files. 26 | */ 27 | interface ControllerInterface 28 | { 29 | /** 30 | * Initialize Controller - return false if not runnable for any reason. 31 | * 32 | * @return bool 33 | */ 34 | public function init(): bool; 35 | 36 | /** 37 | * Check if an action should always be JSON. 38 | * 39 | * Defaults to false. 40 | * 41 | * @param string $actionName 42 | * @return bool 43 | */ 44 | public function alwaysJson(string $actionName): bool; 45 | } 46 | -------------------------------------------------------------------------------- /Interfaces/DatabaseDetailsInterface.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | namespace Feast\Interfaces; 20 | 21 | use Feast\ServiceContainer\ServiceContainerItemInterface; 22 | 23 | interface DatabaseDetailsInterface extends ServiceContainerItemInterface 24 | { 25 | final public const INTERFACE_NAME = self::class; 26 | 27 | public function cache(): void; 28 | 29 | public function getDataTypesForTable(string $table, string $connection = 'Default'): array; 30 | 31 | public function setDatabaseFactory(DatabaseFactoryInterface $dbFactory): void; 32 | } 33 | -------------------------------------------------------------------------------- /Interfaces/DatabaseFactoryInterface.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Interfaces; 22 | 23 | use Feast\Exception\ServerFailureException; 24 | use Feast\ServiceContainer\ServiceContainerItemInterface; 25 | 26 | /** 27 | * Manage the database connections. 28 | * Direct access is frowned upon, let the factory manage it for you. 29 | * 30 | */ 31 | interface DatabaseFactoryInterface extends ServiceContainerItemInterface 32 | { 33 | final public const INTERFACE_NAME = self::class; 34 | 35 | final public const DEFAULT_CONNECTION = 'default'; 36 | 37 | /** 38 | * Get the specified connection 39 | * 40 | * @param string $connection 41 | * @return DatabaseInterface 42 | * @throws ServerFailureException 43 | */ 44 | public function getConnection(string $connection = self::DEFAULT_CONNECTION): DatabaseInterface; 45 | } 46 | -------------------------------------------------------------------------------- /Interfaces/ErrorLoggerInterface.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Interfaces; 22 | 23 | use Feast\ServiceContainer\ServiceContainerItemInterface; 24 | use Throwable; 25 | 26 | interface ErrorLoggerInterface extends ServiceContainerItemInterface 27 | { 28 | /** 29 | * Error handler for all errors (not exceptions). 30 | * 31 | * @param int $errno 32 | * @param string $errstr 33 | * @param string $errfile 34 | * @param int $errline 35 | * @return bool 36 | */ 37 | public function errorHandler(int $errno, string $errstr, string $errfile, int $errline): bool; 38 | 39 | /** 40 | * Exception handler. 41 | * 42 | * @param Throwable $exception 43 | * @param bool $caught 44 | * @return bool 45 | */ 46 | public function exceptionHandler(Throwable $exception, bool $caught = false): bool; 47 | } 48 | -------------------------------------------------------------------------------- /Interfaces/FeatureFlagInterface.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Interfaces; 22 | 23 | use Feast\ServiceContainer\ServiceContainerItemInterface; 24 | 25 | /** 26 | * 27 | * Class to manage feature flags. 28 | */ 29 | interface FeatureFlagInterface extends ServiceContainerItemInterface 30 | { 31 | public const INTERFACE_NAME = self::class; 32 | 33 | public function isEnabled(): bool; 34 | 35 | } 36 | -------------------------------------------------------------------------------- /Interfaces/JobInterface.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Interfaces; 22 | 23 | interface JobInterface 24 | { 25 | public function run(): bool; 26 | } 27 | 28 | -------------------------------------------------------------------------------- /Interfaces/MainInterface.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Interfaces; 22 | 23 | use Feast\Exception\Error404Exception; 24 | use Feast\Exception\ServerFailureException; 25 | use Feast\ServiceContainer\NotFoundException; 26 | use Feast\ServiceContainer\ServiceContainer; 27 | 28 | /** 29 | * Main entry point of the Application. 30 | */ 31 | interface MainInterface 32 | { 33 | 34 | public function __construct(ServiceContainer $serviceContainer, string $runAs); 35 | 36 | /** 37 | * Main Program execution loop. Called from Binary.php and from public/index.php. 38 | * 39 | * @throws NotFoundException 40 | * @throws Error404Exception 41 | * @throws ServerFailureException 42 | */ 43 | public function main(): void; 44 | } 45 | -------------------------------------------------------------------------------- /Psr/Container/ContainerExceptionInterface.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Router; 22 | 23 | class RouteData 24 | { 25 | public string $pattern; 26 | public string $routePath; 27 | 28 | public function __construct( 29 | public string $module, 30 | public string $controller, 31 | public string $action, 32 | public string $name, 33 | public array $arguments, 34 | string $pattern, 35 | string $routePath 36 | ) { 37 | $this->pattern = '/^' . str_replace('/', '\\/', $pattern) . '$/'; 38 | $this->routePath = str_replace('?:', ':', $routePath); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /ServiceContainer/ContainerException.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\ServiceContainer; 22 | 23 | use Exception; 24 | use Psr\Container\ContainerExceptionInterface; 25 | 26 | class ContainerException extends Exception implements ContainerExceptionInterface 27 | { 28 | 29 | } 30 | -------------------------------------------------------------------------------- /ServiceContainer/NotFoundException.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\ServiceContainer; 22 | 23 | use Exception; 24 | use Psr\Container\NotFoundExceptionInterface; 25 | 26 | class NotFoundException extends Exception implements NotFoundExceptionInterface 27 | { 28 | 29 | } 30 | -------------------------------------------------------------------------------- /ServiceContainer/ServiceContainerItemInterface.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\ServiceContainer; 22 | 23 | interface ServiceContainerItemInterface 24 | { 25 | } 26 | -------------------------------------------------------------------------------- /Traits/DebugQuery.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Traits; 22 | 23 | use Feast\Date; 24 | 25 | trait DebugQuery 26 | { 27 | /** 28 | * @param string $query 29 | * @param array $bindings 30 | * @return string 31 | */ 32 | public function debugQuery(string $query, array $bindings): string 33 | { 34 | /** @var string|int|float|bool|Date|null $binding */ 35 | foreach ($bindings as $binding) { 36 | $location = strpos($query, '?'); 37 | if ($location === false) { 38 | return $query; 39 | } 40 | $query = substr_replace( 41 | $query, 42 | '\'' . str_replace('?', '{question_mark}', (string)$binding) . '\'', 43 | $location, 44 | 1 45 | ); 46 | } 47 | 48 | return str_replace('{question_mark}', '?', $query); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /Traits/DependencyInjected.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | namespace Feast\Traits; 22 | 23 | use Feast\ServiceContainer\ContainerException; 24 | use Feast\ServiceContainer\NotFoundException; 25 | use Feast\ServiceContainer\ServiceContainer; 26 | 27 | trait DependencyInjected 28 | { 29 | /** 30 | * Check if the instantiated item is already in the Service Container. Throws if item found. 31 | * 32 | * @param mixed ...$arguments 33 | * @throws ContainerException 34 | * @throws NotFoundException 35 | */ 36 | public function checkInjected(mixed ...$arguments): void 37 | { 38 | $className = defined(static::class . '::INTERFACE_NAME') ? (string)static::INTERFACE_NAME : static::class; 39 | if (di(ServiceContainer::class)->has($className, ...$arguments)) { 40 | throw new ContainerException('Attempted to instantiate class that is in DI Container' . $className); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /bootstrap.php: -------------------------------------------------------------------------------- 1 | 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | declare(strict_types=1); 20 | 21 | ########################################################## 22 | # THIS VERSION OF THE BOOTSTRAP FILE ALLOWS PSALM TO RUN # 23 | # DO NOT MODIFY THIS FILE AT ALL # 24 | ########################################################## 25 | # 26 | 27 | use Feast\Autoloader; 28 | use Feast\Interfaces\RouterInterface; 29 | 30 | if (file_exists(__DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php')) { 31 | /** @psalm-suppress MissingFile */ 32 | require_once(__DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php'); 33 | } 34 | $routes = di(RouterInterface::class); 35 | // Any custom routes below 36 | 37 | $autoLoader = di(Autoloader::class); 38 | // Any custom autoload mappings below 39 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "feast/framework", 3 | "description": "Feast Framework", 4 | "license": "Apache-2.0", 5 | "authors": [ 6 | { 7 | "name": "Jeremy Presutti", 8 | "email": "Jeremy@Presutti.us", 9 | "homepage": "https://github.com/jpresutti", 10 | "role": "Developer" 11 | } 12 | ], 13 | "require": { 14 | "php": "^8.2.0", 15 | "ext-pdo": "*", 16 | "ext-xml": "*", 17 | "ext-readline": "*", 18 | "ext-ctype": "*", 19 | "ext-simplexml": "*", 20 | "ext-libxml": "*", 21 | "ext-fileinfo": "*" 22 | }, 23 | "suggest": { 24 | "ext-mysql": "*", 25 | "ext-pdo_mysql": "*", 26 | "ext-curl": "*" 27 | }, 28 | "require-dev": { 29 | "psalm/phar": "^4.7" 30 | }, 31 | "autoload": { 32 | "psr-4": { 33 | "Feast\\": ".", 34 | "Psr\\": "Psr" 35 | }, 36 | "files": [ 37 | "DependencyInjector.php" 38 | ] 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /configs/config.local.php: -------------------------------------------------------------------------------- 1 | cancelDeferral(); 32 | ``` 33 | 34 | The above code would only echo `This is first.` 35 | 36 | ## Deferred Abstract class 37 | 38 | The `Deferred` abstract class must be extended. This class has a required method `deferredAction` that must be 39 | implemented in the child. There are no mandatory constructor arguments for this class and can be used for more dynamic 40 | use cases. -------------------------------------------------------------------------------- /docs/first-controller.md: -------------------------------------------------------------------------------- 1 | [Back to Index](index.md) 2 | 3 | # Your First Controller 4 | 5 | When FEAST installs, it creates the `/Controllers/IndexController` class and `IndexGet` method for you. The base url 6 | of `/` will [route](routing.md) to this controller/action by default. 7 | 8 | In addition, `/Views/layout.phtml` is created as well as `/Views/Index/index.phtml`. The layout file is designed for 9 | your overall template and includes some boilerplate for putting in CSS/JS without having to write script tags or link 10 | tags. 11 | 12 | In your Index Controller class, indexGet method, you can place any business logic or calls to other business logic. In 13 | the controller, 14 | `$this->view` can hold any variables you need for your [View](view.md) file. If you do not call a redirect or a forward, 15 | your associated view file will be rendered. 16 | 17 | Your main content for your home page should go in the `Views/Index/index.phtml`. It has access to all variables assigned 18 | to your view as well as all the functions of the View class with `$this`. -------------------------------------------------------------------------------- /docs/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FeastFramework/framework/63387eedde1b4caa8e1ad05bda27adeb072792b3/docs/logo.png -------------------------------------------------------------------------------- /docs/plugin.md: -------------------------------------------------------------------------------- 1 | [Back to Index](index.md) 2 | 3 | # Working with Plugins 4 | 5 | FEAST allows you to create Plugins for pre-processing and post-processing of a request. This can be used for (among other things) 6 | sanitizing JSON requests to remove sensitive data from the returned view, sending emails or queueing jobs, and throttling requests. 7 | 8 | A plugin is created through the FEAST [CLI](cli.md#feastcreateplugin). To enable a plugin, simply add it to your configuration file. 9 | 10 | Plugins have the following 4 methods that you can define. 11 | 12 | 1. `preDispatch` - This method is ran before a web request is handed off to a controller. 13 | 2. `postDispatch` - This method is ran after the web request has finished processing in the controller, 14 | but before the view has been rendered. 15 | 3. `CLIpreDispatch` - This method is ran before a cli request is handed off to a controller. 16 | 4. `CLIpostDispatch` - This method is ran after the cli request has finished processing in the controller. 17 | 18 | In addition, you can define any other helper methods in your plugin. If you wish to use the plugin standalone, with no automatic 19 | hooks, simply do not add it to your configuration file. -------------------------------------------------------------------------------- /docs/release-schedule.md: -------------------------------------------------------------------------------- 1 | [Back to Index](index.md) 2 | 3 | # FEAST Release Schedule 4 | 5 | FEAST follows the [Semantic Versioning](https://semver.org/) specification. The specification is in `MAJOR.MINOR.PATCH` 6 | format, with releases prefixed with `v`. For example, `v1.2.4` is major release 1, minor release 2, patch release 4. 7 | 8 | FEAST is not on a set release schedule for minor or patch releases. FEAST is uniquely positioned to release rapidly with 9 | safety, due to the code coverage policy of 100% test coverage and static type inference 10 | (see [Contributing to FEAST](CONTRIBUTING.md)). As such, new minor and patch releases are released when bugs are 11 | found or new behavior is implemented. 12 | 13 | FEAST attempts to align major releases with the PHP minor release schedule. Backwards compatibility breaks are 14 | usually reserved for release on the day of PHP minor releases. 15 | 16 | -------------------------------------------------------------------------------- /docs/throttle.md: -------------------------------------------------------------------------------- 1 | [Back to Index](index.md) 2 | 3 | # Throttle Plugin 4 | 5 | FEAST ships with an optional plugin for throttling requests from the same IP. This plugin is not enabled by default, but 6 | can be easily configured by adding a few lines to your `configs/config.php` file. 7 | 8 | To enable, simply add `'plugin.throttle' => \Plugins\Throttle::class,` to the appropriate environment. 9 | 10 | The folder `storage/throttle` MUST be writeable by the web server. 11 | 12 | The Throttle plugin has the following options. 13 | 14 | 1. `throttle.maxrequests` - defaults to 200 15 | 2. `throttle.maxrequesttime` - defaults to 20. 16 | 3. `error.throttle.url` - defaults to `/error/rate-limit` 17 | These options means that if a user exceeds 200 requests in a 20 second window, they should be forwarded 18 | to `/error/rate-limit`. Note that plugins will all still run on the rate-limit url, as it will not be throttled. -------------------------------------------------------------------------------- /logos/feast-simple-transparent-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FeastFramework/framework/63387eedde1b4caa8e1ad05bda27adeb072792b3/logos/feast-simple-transparent-small.png -------------------------------------------------------------------------------- /logos/feast-simple-transparent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FeastFramework/framework/63387eedde1b4caa8e1ad05bda27adeb072792b3/logos/feast-simple-transparent.png -------------------------------------------------------------------------------- /logos/feast-simple.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FeastFramework/framework/63387eedde1b4caa8e1ad05bda27adeb072792b3/logos/feast-simple.png -------------------------------------------------------------------------------- /logos/feast-transparent-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FeastFramework/framework/63387eedde1b4caa8e1ad05bda27adeb072792b3/logos/feast-transparent-small.png -------------------------------------------------------------------------------- /logos/feast-transparent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FeastFramework/framework/63387eedde1b4caa8e1ad05bda27adeb072792b3/logos/feast-transparent.png -------------------------------------------------------------------------------- /logos/feast.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FeastFramework/framework/63387eedde1b4caa8e1ad05bda27adeb072792b3/logos/feast.png -------------------------------------------------------------------------------- /logos/mini-transparent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FeastFramework/framework/63387eedde1b4caa8e1ad05bda27adeb072792b3/logos/mini-transparent.png -------------------------------------------------------------------------------- /logos/mini.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FeastFramework/framework/63387eedde1b4caa8e1ad05bda27adeb072792b3/logos/mini.png -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | FeastTests 6 | 7 | 8 | 9 | 10 | . 11 | Form.php 12 | Email.php 13 | Main.php 14 | Attributes 15 | Collection 16 | Traits/Collection.php 17 | Controllers 18 | 19 | 20 | FeastTests 21 | Install 22 | PsalmLoader.php 23 | ../Autoloader.php 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | --------------------------------------------------------------------------------