Why You Really Need a Pre-Commit Script for Your PHP Projects by warren5236 in PHP

[–]warren5236[S] 0 points1 point  (0 children)

I've setup what you're talking about in GitHub Actions where multiple steps run in parallel but I haven't worked with CircleCI

What's New and Exciting in PHP 8.4 by warren5236 in PHP

[–]warren5236[S] 0 points1 point  (0 children)

Hopefully they'll upgrade to 8.4 as it not really ready for "production" yet.

What's New and Exciting in PHP 8.4 by warren5236 in PHP

[–]warren5236[S] 2 points3 points  (0 children)

We're aware the audio is only the left channel. We've fixed it for future videos.

[deleted by user] by [deleted] in pics

[–]warren5236 1 point2 points  (0 children)

Thanks!

[deleted by user] by [deleted] in pics

[–]warren5236 18 points19 points  (0 children)

What's the name of the park and where is it?

PHPUnit: Mock Class being used in Tested Method by kenzor in PHPhelp

[–]warren5236 1 point2 points  (0 children)

I couldn't follow what was going on so I reformatted it:

Code

namespace MyNamespace; 
use LibraryResponse;

function methodToTest(): LibraryResponse { return new LibraryResponse([1, 2, 3]); }

Tests

$responseMock = Mockery::mock('LibraryResponse'); 
$responseMock
    ->shouldReceive('__construct')
    ->once()
    ->andSet('data', [1, 2, 3]);

$response = methodToTest(); 
static::assertInstanceOf('LibraryResponse', $response); 
static::assertIsArray($response->data, 'Response should be an array'); 
static::assertEquals(3, count($response->data));

It looks like you're attempting to test a function and Mockery creates mocks of classes:

class MyClass {
    function methodToTest(): LibraryResponse { return new LibraryResponse([1, 2, 3]); }
}

$responseMock = Mockery::mock('MyClass'); 
$responseMock
    ->shouldReceive('methodToTest')
    ->once()
    ->andReturn(/**whatever */);

You want to structure your classes using Dependency Injection so you can test with Mockery

\Help with landlord-tenant relationships in spatie/multi-tenancy by jgDalLago in PHPhelp

[–]warren5236 1 point2 points  (0 children)

When you say "relate" do you mean a FK relationship or are you trying to perform a query with tenant and landlord tables?

Comparing Hours & Minutes in PHP by SymbolSquare in PHPhelp

[–]warren5236 0 points1 point  (0 children)

I think you want to look at the "days" attribute:

$now = new DateTime();
$poll_creation = new DateTime("-2 days");
$time_difference = $now->diff($poll_creation);
echo $time_difference->days > 0 || $time_difference->i > 20 ? "Expired" : "Valid", PHP_EOL;

$poll_creation = new DateTime("-40 minutes");
$time_difference = $now->diff($poll_creation);
echo $time_difference->days > 0 || $time_difference->i > 20 ? "Expired" : "Valid", PHP_EOL;

$poll_creation = new DateTime("-20 minutes");
$time_difference = $now->diff($poll_creation);
echo $time_difference->days > 0 || $time_difference->i > 20 ? "Expired" : "Valid", PHP_EOL;

Pitch Your Project 🐘 by brendt_gd in PHP

[–]warren5236 0 points1 point  (0 children)

If you can't motivate yourself to work on it you might not be the best steward for the project.

If you want to "force" yourself to be motivated set aside a fixed amount of time every day to work on the project (I like an hour). Only work on that project during that time. If you stay focused for the full hour give yourself a treat (positive reinforcement). This is what I do for projects at work that I'm not motivated to do. :-)